Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 Today 06:41:08

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,680
GitHub Twitter

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

#2 Today 07:51:35

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,394
Website GitHub Mastodon Twitter

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

#3 Today 16:11:54

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,680
GitHub Twitter

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

#4 Today 16:43:15

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,394
Website GitHub Mastodon Twitter

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

#5 Today 16:45:45

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,217
Website GitHub

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

#6 Today 16:53:48

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,680
GitHub Twitter

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

Board footer

Powered by FluxBB