0

I am trying to allow a user the ability to select code snippets (widgets?) to show in a sidebar area on a page-by-page basis. These snippets could have plain old HTML code or could be EE channel entries loops.

I setup a Code Snippets channel with a single "code_snippet" textarea field (format NONE) where the code would be pasted in. Then in the Pages channel, I created a Playa field called "page_sidebar_items" that pulls from the Code Snippets channel.

On my template, plain old HTML code will display correctly but EE channel entries tags (actually, I'm using a Low Events tag) will not. It will output the actual EE code on the page instead of parsing it first.

Is there a way to tell EE to parse that code before displaying it? I have tried placing parse="inward" in a few different places with no luck.

I have tried this:

{exp:channel:entries channel="Pages" disable="member_data|pagination|categories|category_fields"}
    {exp:playa:children var="page_sidebar_items"}
        {code_snippet}
    {/exp:playa:children}
{/exp:channel:entries}

And this:

{exp:channel:entries channel="Pages" disable="member_data|pagination|categories|category_fields"}
    {page_sidebar_items}
        {code_snippet}
    {/page_sidebar_items}
{/exp:channel:entries}

Code Snippet:

<h3>Upcoming Events</h3>
{exp:low_events:entries channel="events" show_future_entries="yes" sort="asc" dynamic="no" disable="member_data|pagination|categories"}
<p><span class="sidebar-event-date">{if '{event_dates:one_day}' == 'y'}{event_dates:start_date format="%F %j, %Y"}
{if:else}
{if '{event_dates:start_date format="%F"}' == '{event_dates:end_date format="%F"}'}
{event_dates:start_date format="%F %j"}-{event_dates:end_date format="%j, %Y"}
{if:else}
{event_dates:start_date format="%F %j"}-{event_dates:end_date format="%F %j, %Y"}{/if}
{/if}</span><br />
<a href="{page_url}">{title}</a><br />
<span class="sidebar-event-host">{event_host}</span><br />
{event_city}, {event_state}<br />
<a href="{page_url}">Details</a>
</p>
{/exp:low_events:entries}

This code snippet works fine if placed directly into my template, but does not work (HTML bits are fine but EE bits are not parsed) when pulled from the channel via Playa.

What am I missing here? Thanks in advance!

Side Note: I've also tried using Low Variables instead (code snippets live in LV and add a LV fieldtype to my Code Snippets channel) with pretty much the same results. If I could get that approach working, I would prefer that over code living in a channel.

Versions: EE 2.9.2, Low Events 1.3.1, Structure 3.3.14.7, Playa 4.5.2, Low Variables 2.5.0

2
  • Does the title field of the snippet pull through ok?
    – Todd
    Commented Apr 20, 2015 at 19:31
  • No. It is {title} in the rendered output.
    – Amy Witty
    Commented Apr 20, 2015 at 19:44

1 Answer 1

2

Wow! This looks so complex...

Please, try using this first party add-on:

{exp:channel:entries channel="Pages" disable="member_data|pagination|categories|category_fields"}
  {exp:playa:children var="page_sidebar_items" parse="inward"}
    {exp:allow_eecode}
      {code_snippet}
    {/exp:allow_eecode}
  {/exp:playa:children}
{/exp:channel:entries}

I confess that I never used it, but maybe it can help you.

There's a good list of first party add-ons on EECMS user guide.

0

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.