1

Ok I have brands for products stored as a Playa so I can do various things with them...obviously simple things like:

{cf_paper_brand} {title} {/cf_paper_brand}

However, later I want to include a list of articles based on that product's brand. I am storing these related articles in low variables(of playas) -

lv_brand1_articles, lv_brand2_articles

etc.

Thus my basic issue is I want to retrieve/choose the appropriate low variable based on the playa brand field.

This seems like it should be easy, and certainly I can do it with a bunch of conditionals I guess. But I am thinking there must be a more elegant solution...basically, I just need to get the brand title once and then use this in a few spots as a 'stub' when retrieving the low variable

In pseudo code:


if cf_product_brand == "brand1" then
    {exp:low_variables:parse var="{lv_brand1_articles}" var_prefix="brand_articles"}
        {brand_articles:title}
    {/exp:low_variables:parse}
else if cf_product_brand == "brand1"
    {exp:low_variables:parse var="{lv_brand2_articles}" var_prefix="brand_articles"}
        {brand_articles:title}
    {/exp:low_variables:parse}
else if....

etc... but for a LOT of brands, and I have related articles, links, and files. So I will end up with a block of 30+ conditionals - which sucks. Basically, I want to keep this mess of conditionals out of my template or at least in one spot in the template.

SO - If could set a stub of the brand title somehow, then retrieve {lv_{stub}_articles} - that would work....but I can't seem to do this. I have tried with stash but I am new to all the parse order issues and getting confused. I am thinking maybe I need to use a low variable with a pre_parse thing but can't quite seem to get it ...

Any help much appreciated!! I am relatively new to EE and Stack Exchange etc. Hope I have asked correctly!

(And note - the brand is not available in the segment_x variables as it's not in the URL. I could in theory put it there, but I'd really prefer not to)

1 Answer 1

0

Ok for future reference, this is how I did it:



                {exp:playa:children field='cf_paper_brand' var_prefix="brand"}
                    {exp:low_variables:parse var="lv_links_{brand:url_title}" var_prefix="brand_links"}
                             ****** B- {brand_links:link_text}{brand_links:link_description}
                    {/exp:low_variables:parse}
                {/exp:playa:children}             

Predictably, this seems obvious now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.