Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Using output_form with multiple targets - what's the formula?
I would like to use output_form with multiple forms, with bonus points for an efficient (or most efficient) route in.
In this case I have 7 misc forms (named plaintext_location_1of7 […] plaintext_location_7of7). If I chain >1 of them together with a single output_form scaffold and separate commas, it errors out:
<txp:output_form form="plaintext_location_1of7,plaintext_location_2of7" />
Tag error: <txp:output_form form="plaintext_location_1of7,plaintext_location_2of7" /> -> Textpattern Notice: No form data found for: manifesto-v1.plaintext_location_1of7,plaintext_location_2of7. Issue detected while parsing form html_diagnostics on page default
textpattern/lib/txplib_misc.php:3619 trigger_error()
textpattern/lib/txplib_misc.php:3651 fetch_form()
textpattern/publish/taghandlers.php:446 parse_form()
output_form()
textpattern/vendors/Textpattern/Tag/Registry.php:140 call_user_func()
textpattern/lib/txplib_publish.php:540 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_publish.php:429 processTags()
textpattern/lib/txplib_misc.php:2300 parse()
textpattern/lib/txplib_publish.php:528 splat()
textpattern/lib/txplib_publish.php:429 processTags()
Both forms exist as plaintext miscellaneous forms, they’re both callable individually, but chaining them with a comma doesn’t work. I can work around with one output_form per form, but I’m wondering if there’s another broadly sane way of approaching this.
Thank you.
Last edited by gaekwad (Today 14:39:37)
Offline
Re: Using output_form with multiple targets - what's the formula?
Hmm. I can’t recall if adding breakby="," might work. Not sure if output_form is wired that way, and I’m not near a machine I can easily test it on.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Using output_form with multiple targets - what's the formula?
Bloke wrote #341350:
Hmm. I can’t recall if adding
breakby=","might work. Not sure if output_form is wired that way, and I’m not near a machine I can easily test it on.
Thanks, Bloke. I had tried that prior to my post, similar error to above:
Tag error: <txp:output_form breakby="," form="plaintext_location_1of7,plaintext_location_2of7,plaintext_location_3of7,plaintext_location_4of7,plaintext_location_5of7,plaintext_location_6of7,plaintext_location_7of7" /> -> Textpattern Notice: No form data found for: manifesto-v1.plaintext_location_1of7,plaintext_location_2of7,plaintext_location_3of7,plaintext_location_4of7,plaintext_location_5of7,plaintext_location_6of7,plaintext_location_7of7. Issue detected while parsing form textpattern_html_main on page default
I’ve bodged around it in the meantime with a sequence of output_form scaffolds, but if there’s a way to have fewer db queries I’m all ears.
Offline
Re: Using output_form with multiple targets - what's the formula?
Oleg revealed here that you can use the pipe symbol to specify multiple forms, but it will only act on the first match.
Other alternatives, wrap it in rah_repeat or smd_each, or use Textpattern 4.9’s own ‘looper’ via a detour to txp:variable:
<txp:variable name="form_loop" output value="form_one, form_two, form_three, form_four, form_five, form_six, form_seven" breakby="," breakform="form_loop_item" />
and a ‘misc’-type breakform:
<txp:output_form form='<txp:yield item />' />
There’s currently a test of that on dev-demo.textpattern.co/dev/ until the next refresh in 20 minutes or so.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Using output_form with multiple targets - what's the formula?
As weird as it looks, comma is accepted in form names, so using it as separator in form attribute is risky. We do one exception, though:
<txp:output_form form yield="plaintext_location_1of7,...,plaintext_location_7of7" />
will retrieve and store in cache all forms at once, but you’d still need to output them individually.
Offline
Re: Using output_form with multiple targets - what's the formula?
etc wrote #341353:
We do one exception, though … will retrieve and store in cache all forms at once, but you’d still need to output them individually.
Hehe, I was just about to post that. You’d mentioned it here a while ago, and in this recent GitHub issue, where Bloke also posted a potential php snippet for looping over prefetched forms.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Using output_form with multiple targets - what's the formula?
Thank you, jakob & etc – much appreciated!
Offline