|
9886ab482258e3724ed7b49ccca7f08e
|
more logic please!by Christina - Miss Manners - 10:40AM, Jan 30, 2007 |
|
I’m finding myself pushing at the limits of the liquid/admin system these past two weeks, & would like to request some additions to the logic which would make it possible to do away with a lot of manual labour, diverse hacks, multiple nested conditionals and sheer frustration. This sums up a few of the requests/comments I’ve made recently. In order of priority: 1) editable handles : Tobi, you mentioned that you’ve been intending to make product handles etc. editable. This would be fantastic for a consistent system of product reference & would help greatly in setting up bilingual stores, editing product names without 404 penalties and so on. 2) more string manipulation :
3) choice of “and” or “or” as conditionals in smart collection setup as requested here in May, here in August, and here in December. 4) more booleans in liquid – in particular “or” – as requested here last April and here again in October 5) Other things that have been mentioned before are: 6) And the biggie: custom fields...one day? maybe? then I wouldn’t have to use my “blog as product description” hack anymore. Sorry for posting such a tall order before breakfast, but I’ve really reached the end of what I can do with the system as it stands, and I would love to do more! It’s such a lovely thing you guys created, I’d really like to be able to use all of its potential. And with that, ummm…have a beautiful day! edited to add this, which I’m battling with: 7 – enlarged variable scope for example: allow for this:
and this:
That could solve A LOT of problems – fix all the related products problems quite elegantly for example! I’ll share the code as soon as I hatch it, as soon as I can use variables in more contexts – promise! Last edited 01:47PM, Jan 30, 2007 |
|
|
Thanks for the list christina. I agree with the need for all of these things. You are really pushing the boundaries of liquid and our theming system so its great to hear from you what the most pressing issues are in this area. 1) Ok soon 2) truncate works like this. I’ll add if a contains b to liquid. 3) Thats unlikely to happen soon. Very very complicated implementation and UI. 4) Tricky, i get this request a lot from the mephisto crowd. I’ll see what it takes. 5) I’d rather get rid of product types entirly, they are really superseded by collections. They are only around now becuase of the convenience. I don’t quite understand the second point, you can add a product to a collection on the product page, can you not? 6) Custom fields are something i really want eventually but it will probably take a while till we can tackle this one. 7) Would be nice… i spend a transatlantic flight working on this before but didn’t come up with a satisfactory result. There is hoping that i get to revisit this. ---
Tobias Lütke
|
|
|
& thank you very much for the quick answer & positive response, Tobi! 1) am delighted! no problem, variable assigned. but I couldn’t understand why this works: and links to a collection page with related products (which is not quite what I want but it’s a start.) - but this just throws up a liquid error: where the problem is obviously this: and that’s just so weird!
|
|
|
so with my new truncating skills, I’m now trying this:
but var base_sku returns the untruncated variant.sku, so I’m supposing it doesn’t read the filter. is this syntax not accepted?
|
|
|
Try this
Couldn’t you just go for this?
Or is there a reason to assign variant.sku to base_sku? — Last edited 12:38AM, Jan 31, 2007 |
|
|
Currently it should never work to use Similarly you cannot use filters in Can’t your problem be better solved by a links list though? ---
Tobias Lütke
|
|
|
Ok, i’ll explain the use: When I set up my shop, and looked at what one could do with variants vs. products, I decided not to use variants for identical products of a different colour, but to list them as independent products because 1)I wanted to be able to display “Item X – blue” in the same way as Item X – red”, and 2) I wanted to be able to tag them independently. So now, I have products that are almost identical, with the only difference being the colour. They’re scattered all over the collection, with no way of getting from “Item X – red” to “Item X – blue”. And that bothers me. What I’m trying to do is say on product page “Item X- red”, display small pictures of “Item X – blue” and “Item X – green” with links, to say, “if you prefer this same thing in blue or green, go here”. The SKU structure is as follows:
where the first three letters are the code for the manufacturer, the next group of three figures the code for the item model, and the last group of three figures the color code. So what I want to do is chop the last three digits off the SKU, and have that as a variable called “base_sku” which will indicate the product model without the colour. So variant.sku (9 digits) is not the same thing as base_sku (6 digits). This is what I’m trying to do with:
In a second step, I’d like to do a forloop for products in products that contain “base_sku”, and list them on the product page. (once we have “a contains b” in liquid). And that should take care of the display of identical products of a different colour on any given product page. But if this kind of logic is impossible, then I’ll have to try something else. I was trying to avoid setting up collections for each of the identical product groups, with linklists and the whole kit & caboodle. I do miss some more powerful variable use though. Or – another way around this would be to be able to attach independent tags to the variants, i.e. for item X – a group of shared tags, and for variant “item X – red” independent tag “red” and for variant “item X – blue” independent tag “blue”. But that seems like a much more intrusive change to the existing system. Hence my coding attempts. Voilà!
|
|
|
bumpety-bumpety-bump…
would be extremely vastly incredibly useful right now! please soon?
|
|
|
Ok, where do we find ALL the liquid options available. I see above there is an assign option. Haven’t found it documented anywhere yet. I see on the leetsoft site, an ifchanged option. The assign option looks like it allows you to assign a value to a variable, but I’ve tried to use it to just assign text, but that does not work.. eg:
|
|
|
yes – to the last question. it’s documented here: http://help.shopify.com/design/show/The+Shopify+Theme+Guide & other info availabe in the wiki, specifically in “pages and tags”
|
|
|
So I’m guessing I’ve run into another limitation of Liquid??
|
|
|
i’m puzzled as to what you’re trying to achieve by this – as i parse it this would give you: product 1 variant 1 product 2 variant 1 and so on - so this would capture your odd variants, and i suppose you’d have another loop to capture your even ones. that makes 2 forloops for the same variants – i.e. double the server calls. if you want to just style variants differently, you could do: and then style your items with css:
|
|
|
I’m trying to get around coding a bazillion lines of code to deal with my various tables I want to implement to deal with size/colour… I have the tables solution working.. However due to the lack of variable substitution, I have to code each product and each line, as opposed to have a single set of code and passing variables to it. It has been a tad frustrating… For example, I may have a product that has 14 variants. I can put them on two lines in my table, but it requires double the code since I need a line with limit:7 offset:0 and a second line with limit:7 and offset:7. If I could get the offset to be a variable, then, I would only require one set of code. Extrapolate that further, I could build tables using a single set of code, if I could set variables.. Then limit could be variablized, and all would be goodness. Use a case statement for the specific products that require the table module, set the variables, and call one piece of code.
|
|
|
you can use offset: continue which starts where the last limit left off. ---
Tobias Lütke
|
|
|
Ok, well that’s a handy little item… I’ve tested it and now can use a table for variations, with at least a reasonable amount of code. If anyone wants to see a table working for size/type take a look at my test store, http://gams.myshopify.com/products/test-variation. I can post the code here if anyone is interested.
|
|
|
pretty cool! yes i’d be interested in seeing the code.
|
|
|
Ok, here it is….
|
|
Well why don’t you use it then ? ... ;) ---
Tobias Lütke
|
|
|
lol! – you’re a darling, tobi!
|
|
|
@ jeff: thanks, very nice! I hereby nominate you for official shopify cycling champion. p.s. i didn’t know we were allowed to do this:
nice find!
|
|
|
Yeah, finding the tricks within liquid has been shall we say challenging… :) Anyone know how to do if else if endif syntax?? How I thought it should work it doesn’t….
|
|
---
Jared Burns http://www.sofamade.com — Last edited 10:57PM, Feb 12, 2007 |
|
|
Please do consider to update the wiki with all those amazing hacks you guys uncover ;) ---
Tobias Lütke
|
|
|
Is there a way within case to apply two when clauses to the same code?? or is there a way within if to have and/or logic?? eg:
|
|
|
Liquid can’t do that yet. Its one of the most requested features though. I hope someone one day sends me a patch :) ---
Tobias Lütke
|
|
|
can you also add a way to edit the variables of my pasta salad. I’d realllly like to strip out the olives in an easy fashion. =)
|
|
|
---
Tobias Lütke
|
|
|
Tobi, like to point me to info on creating patches for Liquid. I might take a shot at or/and in if, once I know what’s required…
|
|
|
@Jeff – I assume you’d go here:
|
|
|
that would be amazing jeff! ---
Tobias Lütke
|
|
|
Here’s a patch that uses Jeff’s format for collapsing “when” statements: ---
Find a unique handmade greeting card.
|
|
|
It looks like tobi has the “when” statement change I submitted up on Shopify now. Depending on interest, I may look at making the change for “if” statements as well. ---
Find a unique handmade greeting card.
|
|
|
Nice work Eric. I have a few uses for this. Thanks.
|
|
|
eric: thanks a lot for the great submission! Please have a look at if statements. Proper conditions support would be absolutely amazing. I applied the patch as soon as i saw it but i also added comma as a seperator so you can use ---
Tobias Lütke — Last edited 01:08AM, May 01, 2007 |
|
|
Does anyone know if it’s possible to use the mod operator in an if statement, something like this…
It compiles but throws up a liquid error. A bit of background info…I’m looping thru a collection and want to do something to every 3rd product. The only other way I can think of is to have a huge case statement like this…
It’s a workaround, but it’s not ideal :( Any ideas anyone?
|
|
|
You can use the cycle tag for this.
---
Tobias Lütke — Last edited 03:05PM, Jul 05, 2007 |
|
|
doh! now why didn’t I think of that ;) Thanks Tobi, works a treat
|
tobi
Shopify
09:44PM, Jan 30, 2007