1

I'm building a site where I'm having trouble wrapping my head around the logic needed to accomplish what I would like to do.

I have three channels: Brands, Regions, Business Unit.

Brands have a field, brand_region that relates regions to that brand. Business units have a field that relates brands to that business unit.

On the each brand page there are a list of Regions that this brand is available in, for example Ontario, Alberta, Quebec. The Region link needs to take you to the business unit responsible for that brand in the region.

Conversely on the Region page there is a list of brands available and the link for each brand needs to take you to the business unit responsible for that brand in the region currently being viewed.

I'm currently focused on the brand page. So if I'm looking at Volvo for instance and it's available in 3 different regions; Ontario, Alberta, Quebec. The link for each of those needs to be different and go to the business unit responsible for Volvo in that particular region. It's possible that one business unit is responsible for Volvo in Quebec & Ontario and a second business unit is responsible for Volvo in Alberta so that the end result would be Quebec links to business unit 1, Ontario links to business unit 2, and Alberta links to business unit 3.

Removed old code. Simplified code is below but still not working exactly.

{exp:channel:entries channel="regions" limit="1" disable="pagination|member_data|comments" parse="inward"}
  {exp:playa:parents channel="brands" var_prefix="brands" orderby="title" sort="asc" entry_id="{entry_id}"}

  {if no_parents} <p>No Brands available at this location</p> {/if}

    <li>
      {brands:title} | 
      {exp:low_variables:single var='lv-brand-biz-link' preparse:pre_entry_id='{entry_id}' preparse:pre_seg='{last_segment}'}
    </li>            

  {/exp:playa:parents}
{/exp:channel:entries}

And in the Low Variables preparse template

{exp:playa:parents channel="business_unit" var_prefix="bu_link" orderby="title" sort="asc" entry_id="{pre_entry_id}" field_id="68" col="region"}

  {exp:transcribe:uri path="{bu_link:comment_url_title_auto_path}"}

{/exp:playa:parents}

What happens now is that it lists out the correct brands, but in the link it outputs links to all business units and not just the one responsible for that brand in the region currently being viewed.

I'm really stuck on the logic of getting this to work. All help appreciated.

/***** UPDATE ***/ adding scan of what I've got written out on paper. May help with understanding.

enter image description here

  • it wouldn't be as simple as adding parse="inward" to the nested tag would it?? Also, any reason you're not using the native relationships? I've found them to be very good at nested relationships, and the syntax is great. – James Smith Jan 20 '15 at 21:28
  • That did not help. Using Playa because I was under the impression it would work better with nested playa tags than the native field would. Also can't change now as there have been hundreds of entries added in multiple channels all with playa fields. – CreateSean Jan 20 '15 at 22:19
  • So you need to: 1. get a list of regions for each brand 2. get a list of BU for each brand 3. Filter the list of BU by the first list of regions Right? (You could end up with more than one BU per region) – Mark Croxton Jan 21 '15 at 17:42
  • Wouldn't BU therefore need to be related to regions? – Mark Croxton Jan 21 '15 at 17:50
  • updated - replaced old code with simpler almost working code. – CreateSean Jan 21 '15 at 19:36

Your Answer

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

Browse other questions tagged or ask your own question.