Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Occurrences in a "yield" tag
Is it possible (and how) to verify different occurrences into a single conditional yield tag?
For compatibility with a previous short code, I need verify two occurrences into the new one.
The pipe sign seems not working:
<txp:if_yield name"old|new">
...do something wired...
</txp:if_yield>
🤔 💭
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: Occurrences in a "yield" tag
Do you need both occurrences to be true? If so try
<txp:if_yield name="old">
<txp:if_yield name="new">
...do something wired...
</txp:if_yield>
</txp:if_yield>
if only one occurrence is enough, you may need to call the yield twice.
<txp:if_yield name="old">
...do something wired...
</txp:if_yield>
<txp:if_yield name="new">
...do something wired...
</txp:if_yield>
Edited to add that there appears to be a typo in your snippet. If the pipe works, it should be
<txp:if_yield name="old|new">
...do something wired...
</txp:if_yield>
Last edited by colak (Today 07:53:05)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Occurrences in a "yield" tag
Thanks, Yiannis.
I’m familiar with using the conditional structure with the yield tag. I thought there was another way… something more magical. 🪄
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: Occurrences in a "yield" tag
Pat64 wrote #342804:
I’m familiar with using the conditional structure with the yield tag. I
I thought as much. Admittedly I was slightly surprised by the question:)
thought there was another way… something more magical.
Feature request?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Occurrences in a "yield" tag
Hmm, the code does seem to suggest that the match and separator attributes are supported (though it’s not in the docs), but your situation seems to be different: it’s not the value you’re checking but the existence of either your old or your new yield attribute.
But maybe you can use a detour via a variable. Something like:
<!-- use a variable as a detection trigger -->
<txp:variable name="do_wired" trim>
<txp:if_yield name="old">yes</txp:if_yield>
<txp:if_yield name="new">yes</txp:if_yield>
</txp:variable>
<!-- check if the variable is set (= not empty) -->
<txp:if_variable name="do_wired" value="" not>
we're wired …
</txp:if_variable>
Does that work for you?
TXP Builders – finely-crafted code, design and txp
Offline
Re: Occurrences in a "yield" tag
Julian, I’m loving it!
That’s a typical Stef and Oleg’s style. A kind of magical, structural flavor! 🪄
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Pages: 1