Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Using the mothership placeholder for tag attributes in loops?
Another post, this time about replacing rah_repeat with loops.
I want to loop over a comma-separated string and then use each item to output a txp:variable
with the corresponding name, e.g.
<txp:variable name="wochentage" value="mo,tu,we,th,fr,sa,su" breakby="," breakform="weekday_item" output />
and weekday_item
does this:
<txp:if_variable name='business_hours_<+>'>
<p>
<txp:evaluate wraptag="span" class="weekday" escape="upper"><+></txp:evaluate>
<txp:variable name='business_hours_<+>' trim="/([ -]+)/" replace=" – " /> O'clock
</p>
</txp:if_variable>
I can output the <+>
(mothership) on its own, but if I try and use it in a tag attribute, I have no luck*. The variables business_hours_mo
, business_hours_tu
… are all already defined and accessible. They work if I supply them manually.
Interestingly, the <+>
is not capitalised with escape="upper"
either.
(this is all with txp 4.9-dev)
*Oh, I also tried doing:
<txp:variable name="weekday">business_hours_<+></txp:variable>
<txp:variable name=name='<txp:variable name="weekday" />' trim="/([ -]+)/" replace=" – " /> O'clock
But also no luck in this tag-in-tag combination. If I add output
to the first weekday I can verify that the generated variable names are correct, but are just not being used in the tag-in-tag combination.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Using the mothership placeholder for tag attributes in loops?
The mothership replacement happens after the form is parsed. Try replacing <+>
with <txp:yield item />
.
Offline
Re: Using the mothership placeholder for tag attributes in loops?
etc wrote #338938:
The mothership replacement happens after the form is parsed. Try replacing
<+>
with<txp:yield item />
.
That explains it, and the solution feels a bit more intuitive too (well, more like rah_replace_value
).
Thank you (again)!
TXP Builders – finely-crafted code, design and txp
Offline