Reputation: 7941
I'm trying to wrap in my template a block in conditionals:
<div class="widget widget_categories trip_widget">
<div class="kd-widget-title"><h4>Book online</h4></div>
<div class="trip-book-button">
<a href="[(site_url)]book-online.html/#id=[*trip-slug*]">Book now online</a>
</div>
</div>
I need to show that block only if
[*trip-slug*]
is present.
I've read through the forum and the documentation but I can't seem to get the syntax right.
What am I missing?
Upvotes: 0
Views: 2450
Reputation: 857
In Evolution you need the PHx plugin (https://github.com/Temus/PHx) to process resource or template variable tags. With that plugin you could use the following code:
[*trip-slug:ne=`
<div class="widget widget_categories trip_widget">
<div class="kd-widget-title"><h4>Book online</h4></div>
<div class="trip-book-button">
<a href="[(site_url)]book-online.html/#id=[*trip-slug*]">Book now online</a>
</div>
</div>
`*]
Placeholder tags inside Ditto are parsed with a (limited) PHx parser and you could use the following inside a Ditto template without the plugin:
[+trip-slug:ne=`
<div class="widget widget_categories trip_widget">
<div class="kd-widget-title"><h4>Book online</h4></div>
<div class="trip-book-button">
<a href="[(site_url)]book-online.html/#id=[+trip-slug+]">Book now online</a>
</div>
</div>
`+]
In both cases you could also work with the Evolution core if Snippet.
[[if? &is=`[*trip-slug*]:not_empty` &then=`
<div class="widget widget_categories trip_widget">
<div class="kd-widget-title"><h4>Book online</h4></div>
<div class="trip-book-button">
<a href="[(site_url)]book-online.html/#id=[*trip-slug*]">Book now online</a>
</div>
</div>
`]]
Replace the [* *] with [+ +] inside of Ditto template chunks.
Upvotes: 1
Reputation: 420
Use an Output Filter in MODX Revolution (which is what this page is tagged with) or a PHx filter in MODX Evolution (which is what the syntax of your placeholders suggests you're using).
MODX Evolution
[+trip-slug:ne=`
<div class="widget widget_categories trip_widget">
<div class="kd-widget-title"><h4>Book online</h4></div>
<div class="trip-book-button">
<a href="[(site_url)]book-online.html/#id=[*trip-slug*]">Book now online</a>
</div>
</div>
`+]
MODX Revolution
[[*trip-slug:notempty=`
<div class="widget widget_categories trip_widget">
<div class="kd-widget-title"><h4>Book online</h4></div>
<div class="trip-book-button">
<a href="[(site_url)]book-online.html/#id=[*trip-slug*]">Book now online</a>
</div>
</div>
`]]
Upvotes: 1