|
58e50d72c1d5fcd59b5e2bf44c866d4b
|
Empty collections?by pinballki - Member - 08:20AM, Oct 10, 2006 |
|
I’ve been absolutely flying for the last two days with Liquid/Vision, throughly enjoying bringing my design to life but I’ve hit a brick wall this afternoon and seem to be stuck. I’m working on my collection.liquid template and I would like to handle empty collections in my template. Quite simply, if the collection has at least one product display x, otherwise display y. Something like: -
If I add an empty collection to database.yml, then Vision displays a “No Method” error – presumably because my collection template is trying to iterate over a collection (of products) that is either empty, or non-existant. Perhaps Vision behaves differently from Shopify when it comes to empty collections? Perhaps I’m just looking at things from the wrong perspective :-) Can anyone help me out here? |
|
|
OK. Sorry. I’m stupid. The filter size(input) does the trick: -
At least, I think it will…I can’t really test this using Vision as Liquid doesn’t like the collections I’ve setup in database.yml that have no products as members (it’s throwing “No Method” errors). Perhaps I’m getting the syntax wrong in database.yml… In any case I guess it’s time to upload some of my templates to Shopify and do some testing there. The fact remains: I’m loving Shopify/Liquid/Vision. I’m actually enjoying implementing my design. I’ve never had that happen before with an ecommerce templating system. Big thanks to Tobi and the other pixels.
|
|
|
Hey Pinballki. You should be able to use .size everywhere in liquid these days. E.g.
This should work as well:
---
Tobias Lütke
|
|
|
Thanks, Tobi. Makes sense.
|
|
|
Hey Tobi, I have tried this and get the following error: Liquid error: undefined local variable or method `name’ for # My collection.liquid template looks like:
Any idea what that means? Thanks,
|
|
|
hmm this forum eats some of the equal signes ( = ) it should say: ---
Tobias Lütke
|
pinballki
Member
03:33PM, Oct 10, 2006