3

I've created a segment variable for brands that shows in the URL. I want to write an {if} statement that looks at the URL segment for brand and then brings back the products that match the playa field for brand. (ie. If the URL segment says BEAM I want to show all BEAM products that have been selected from the Playa filed). How do I go about doing this? Any suggestions?

Here's a very basic example. This doesn't include the code to only show products with the same name as {segment_6}. Any suggestions? I hope this helps.

<!--I only want to show the code below if segment_6 has something-->
{if segment_6 != ""}  
    {exp:store:search channel="products"}
        {exp:store:product entry_id="{entry_id}"}

                <!--I want all of this code to display the products that match segment_6 with the Playa field brand selected in an entry-->
                {exp:playa:children field="brand"}
                    <h1>{title}</h1>
                {/exp:playa:children}

                <!--this should also display based on the brand in the playa field above-->                                                     
                {product_description}
            {product_image}                                         

        {/exp:store:product}        
    {/exp:store:search}
{/if}

The URL including segment_6. Segment_4 and Segment_5 are comparing prices

4
  • Please add more context to your question so we can better understand what your trying to accomplish. Post sample code too.
    – Siebird
    Jan 3 '13 at 17:28
  • I've updated the questions. I hope this helps. Thanks for chiming in. Very much appreciated. Jan 3 '13 at 18:19
  • Can you add more context for the related channel associated with playa field brand? Does that channel have categories? How are all the BEAM products setup within that channel? Are they all related to a category BEAM?
    – Siebird
    Jan 3 '13 at 19:00
  • The playa field is just a name (ie. Beam, Electrolux, Dyson, etc.). Each product is put into a category (ie. Portable, Canister, etc.). Each product is also assigned a brand (ie. the playa field with the brand name). Any thoughts? Jan 3 '13 at 20:05
1

This is a shot in the dark as I'm still confused on how you have everything configured.

You could just pass the {entry_id} in the {exp:playa:children} playa tag and that would give you all related products that that entry created:

{exp:playa:children entry_id="{entry_id}" field="brand"}
     {title}
{/exp:playa:children}
7
  • Sadly... That won't work in this case. I need to have an {if} statement that looks at the playa field (brands) for the products and then looks at the URL. If in segment_6 it says "Beam" it pulls all products that have the "Beam" brand selected from the Playa field. I hope that made sense. Thanks again for your help. Jan 3 '13 at 21:09
  • Yeah, sorry. Your question is trivial at this point. You'll need to add way more details to your question on the specifics of the channel setup and how the relationships are created. It almost seems to me that you're using playa as a categories alternative. And if that's the case, maybe the playa {exp:playa:sibilings} tag might work.
    – Siebird
    Jan 3 '13 at 21:42
  • Thanks. Sorry this is so frustrating. I've added some comments to the code and added a screenshot of the URL. Maybe this will help. Jan 4 '13 at 15:15
  • Is what's in segment 6 the url_title of the brand entry in the brands channel? Jan 5 '13 at 17:30
  • Hi Jean. Thank you for the response. Segment_6 is just a fake URL. The name that appears in segment_6 is the same name that is in the brands channel. Segment_6 isn't being added by the channel though. I'm just creating a link that includes this segment. I really hope that made sense. Is there a way to display segment_6 from the channel and then call on products that have a specific product that is tagged from the Playa field? Again... Thank you for your time. Jan 5 '13 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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