Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Do not repeat yourself
I have two forms that are identical, apart from one which displays the excerpt field. I’m looking for the simplest/cleanest way to use a single form instead.
Using <txp:article noexcerpt listform="thumb" wraptag="ul" break="li" etc etc />
on my page and this snippet in form thumb.txp:
<txp:if_yield name="noexcerpt">
<txp:excerpt />
</txp:if_yield>
would be the simplest, but doesn’t work as <txp:yield />
only works with shortcodes and output_form.
I can:
- use
<txp:article class="hide--excerpt" listform="thumb" wraptag="ul" break="li" etc etc />
and use css to hide the excerpt, but its kludgy. - call the form with
<txp::thumb noexcerpt etc />
but I’ll need to duplicate all the wraptag, class, break, sort etc attributes for my<txp:article>…
block within form thumb.txp. I’ll also need to account for the article tag’s automatic list/individual_article discrimination. - still use 2 forms thumb.txp and thumb_noexcerpt.txp, each a shell calling on a collection of shortcodes eg.
<txp::thumb_title />, <txp::thumb_image />, etc
. I’m not wild about this approach either. - use
<txp:variable name="noexcerpt" value="1" />
higher up on the page and<txp:if_variable name="noexcerpt" value="1">etc
in my form. This is the simplest approach I can come up with, but I don’t lark ut.
Am I missing something that’s obvious to everyone else?
Last edited by giz (2022-06-24 22:13:08)
Offline
Re: Do not repeat yourself
Untried, but could you use txp:article as a container tag and place your output_form within that. Something like?
<txp:article wraptag="ul" break="li" etc etc>
<txp:output_form form="thumb" noexcerpt />
</txp:article>
Alternatively, if you do use two forms, simply place the output_form
bit in thumb_noexcerpt.txp to call thumb (.txp) with the yield value set.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Do not repeat yourself
Now why didn’t I think of that?
Thank you jakob!
Offline
Pages: 1