Channels and Fields Summary:
Tours
channel - stores a list of all Vacations the site offerstour_specials
field - a Playa field, linked to theSpecials
channel indicating which Special Offers apply to this tour
tour_show_specials_banner
field - a Switch to determine whether to show a special offer banner against this entry, if thetour_specials
field has any entries
Specials
channel - list of Special Offers that can apply to multiple toursPromotions
channel - stores lists of tours our partners want to promote. Though it sounds similar to Specials, it is distinct from a business perspective.promotion_tours
field - a Playa field that stores multipletours
channel entries, indicating which tours are linked to a promotion
The Problem:
- I have created a Promotions page that gets a Promotion, and lists all
tours
associated with the promotion from thepromotion_tours
Playa field - The listing of tours in the Promotion also needs to check whether a tour has a Special Offer running, by looking at the
tour_specials
field in thetours
entry to see if anySpecials
apply - However, all the various code blocks below WILL NOT ever evaluate to true, in the event a tour listed has a Special associated with it
The Code:
Here's the master code block that outputs all Playa entries from the promotion_tours
field (all tours associated with the promotion):
{promotion_tours dynamic_parameters="orderby|sort|limit" orderby="title" sort="asc" limit="10" disable="categories|category_fields|member_data" var_prefix="promotions" paginate="bottom"}
<a href="{promotions:site_url}/{promotions:url_title}">
<img src="{promotions:tour_gallery limit="1"}{promotions:tour_photo_file:thumbnail}{/promotions:tour_gallery}"/>
<!-- PROBLEM STARTS HERE -->
<!-- If we want to show a Special Offer banner... -->
{if promotions:tour_show_specials_banner}
<!-- Then check if there are any linked Specials -->
{if {promotions:tour_specials:total_children} > 0}
<img class="special-offer-banner" src="{site_url}images/site/special-offer.png" alt="Special Offer" title="Special Offer" />
{/if}
{/if}
</a>
{/promotion_tours}
I am using a var_prefix
to allow my Playa entries to be paginated (see here for an explanation).
You can see where the problem starts is with {if promotions:tour_show_specials_banner}
. That statement NEVER evaluates as TRUE, even when I know it should do. The following situations NEVER output anything:
{if promotions:tour_show_specials_banner}
{if tour_show_specials_banner}
{if {promotions:tour_show_specials_banner} == "y"}
{if promotions:tour_show_specials_banner == "y"}
{if {tour_show_specials_banner} == "y"}
I know some are syntactically incorrect but I'm getting to my wits end here...
HOWEVER, if I just output {promotions:tour_show_specials_banner}
in my HTML, it outputs y
in to the content! Which must evaluate as TRUE
!
I'm seriously stumped. Any ideas?