I am trying to use Low Variables, Playa, and a "Features" channel to allow me to select which (3-4) features will be displayed on the Home page. The intent is that either a News, Project, or (Structure) Page may be selected (but never more than one of those) or some unrelated content (body, url, file) may be entered. This is to allow maximum flexibility. Within the "Features" channel there are these fields:
"Features" Channel
- title
- feature_body (textarea -- required)
- feature_related_news (Playa -- select up to 1 entry from "News" channel)
- feature_related_project (Playa -- select up to 1 entry from "Projects" channel)
- feature_related_page (Playa -- select up to 1 entry from "Pages" channel)
- feature_URL (text input -- optional, only entered if no related item)
- feature_image (file)
Low Variables
- Variable: lv_settings_home_features_items (Playa -- select up to 4 entries from "Features" channel, drag and drop to reorder)
I can tell that the variable is being populated (example output: [93] [rainfall-news] Rainfall News [94] [check-out-our-work] Check Out Our Work [95] [donate] Donate
).
Home Template
Each of the different types of related items (news, project, page, or other) requires slightly different formatting and field names.
I would like to do something like this:
<div class="row">
{exp:playa:children var="lv_settings_home_feature_items" limit="3"}
<div class="column one-third">
{if feature_related_news}
{related_entries id="feature_related_news"}
<a href="{page_url}"><img src="{news_image:feature3}" alt="" /></a>
<h3><a href="{page_url}">{/related_entries}{title}</a></h3>
{if:elseif feature_related_project}
{related_entries id="feature_related_project"}
<a href="{page_url}"><img src="{project_image:feature3}" alt="" /></a>
<h3><a href="{page_url}">{/related_entries}{title}</a></h3>
{if:elseif feature_related_page}
{related_entries id="feature_related_page"}
<a href="{page_url}"><img src="{page_image:feature3}" alt="" /></a>
<h3><a href="{page_url}">{/related_entries}{title}</a></h3>
{if:else}
{feature_image}
{if feature_url != ""}<a href="{feature_url}">{/if}<img src="{url:feature3}" alt="" />{if feature_url != ""}</a>{/if}
{/feature_image}
<h3>{if feature_url != ""}<a href="{feature_url}">{/if}{title}{if feature_url != ""}</a>{/if}</h3>
{/if}
<p>{feature_body}</p>
</div>
{/exp:playa:children}
</div>
The code above has related_entries
instead of the applicable Playa code. I started out with relationship fields in the Features channel but then changed them to Playa fields. The code worked when I used a exp:channel:entries channel="Features"
to wrap the entire thing (and just outputted the 3 most recent Features), but once I put the Low Variable in and outer Playa tags on it doesn't work.
The Playa documentation says that to use nested relationships you need to use embeds. How would I structure those to achieve my goal? Or is there some other way? How do I pull the different chunks out of the LV?