0

I have a site that has a custom sidebar for each page and I decided to use Playa to accomplish this. I have the sidebar components displaying on each page as expected but the re-ordering doesn't seem to be working, they just stay in the same order as they are in my template.

Has anyone ever come across this before?

Template code - which is an include on each page:

<div class="sidebar">
{exp:channel:entries channel="page|sub_page|news_page|events_page|music_page|gallery_page|shop_page|reviews_page|contact_page" url_title="{embed:parent}"}
    {exp:playa:children field="sidebar" channel="sidebar_image_component"}
    <div class="sidebarComponent">
        <h4>{title}</h4>
        <a href="{sidebar_image_component_link}" class="linkImage"><img src="{sidebar_image_component_image}" alt="Buy my latest album" /></a>
        <a href="{site_url}/shop" class="siteButton album">Buy Album<i class="fa fa-long-arrow-right"></i></a>
    </div>
    {/exp:playa:children}
    {exp:playa:children field="sidebar" channel="sidebar_text_component"}
    <div class="sidebarComponent">
        <h4>{title}</h4>
        <p>{sidebar_text_component_textarea}</p>
        <a href="{sidebar_text_component_link}" class="siteButton">{link_text}<i class="fa fa-long-arrow-right"></i></a>
    </div>
    {/exp:playa:children}
    {exp:playa:children field="sidebar" channel="sidebar_featured_music"}
    <div class="sidebarComponent">
        <h4>{title}</h4>
        {sidebar_soundcloud_iframe}
    </div>
    {/exp:playa:children}
{/exp:channel:entries}

1
  • Could you explain a little more about reordering - what you're reordering specifically and what you're doing that's not working? Commented Feb 24, 2014 at 14:14

1 Answer 1

0

Playa can’t re-code your template for you; if your template is first outputting any children from the “sidebar_image_component” channel, then from the “sidebar_text_component” channel, and then from the “sidebar_featured_music” channel, that’s the order they’ll appear in.

If you want the entries to be output in the Playa-defined order, you’ll need to merge all of that into a single {exp:playa:children} tag pair:

{exp:playa:children field="sidebar"}
    <div class="sidebarComponent">
        <h4>{title}</h4>

        {if channel_short_name == "sidebar_image_component"}
            <a href="{sidebar_image_component_link}" class="linkImage"><img src="{sidebar_image_component_image}" alt="Buy my latest album" /></a>
            <a href="{site_url}/shop" class="siteButton album">Buy Album<i class="fa fa-long-arrow-right"></i></a>
        {/if}

        {if channel_short_name == "sidebar_text_component"}
            <p>{sidebar_text_component_textarea}</p>
            <a href="{sidebar_text_component_link}" class="siteButton">{link_text}<i class="fa fa-long-arrow-right"></i></a>
        {/if}

        {if channel_short_name == "sidebar_featured_music"}
            {sidebar_soundcloud_iframe}
        {/if}

    </div>
{/exp:playa:children}
2
  • Thanks for this Brandon, works perfectly. I knew it would be something fairly simple but I am new(ish) to EE and Playa. Thanks again. Stephen.
    – user2773
    Commented Feb 24, 2014 at 14:53
  • No worries! Glad that worked for you :) Commented Feb 24, 2014 at 14:54

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.