Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Is this possible: "if form x exists, output it, otherwise do nothing"
I’m getting a bit heavy with form use in one of my projects, and I’m trying to find out of this is possible. At a high level, if a form with a given name exists, then output it (per <txp:output_form />
, and if it doesn’t exist then do nothing and don’t spit out an error.
It’s possible for me to do all of the above aside from the error – just output a given form name regardless of whether it exists or not, and that’s not ideal. Is there a cleaner solution?
Thanks in advance.
Pete
Offline
#2 2009-05-13 20:01:10
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Is this possible: "if form x exists, output it, otherwise do nothing"
gaekwad wrote:
…and don’t spit out an error.
It only spits out an error when the site is in testing or debugging mode, in live mode nothing is displayed…
Offline
Re: Is this possible: "if form x exists, output it, otherwise do nothing"
Els wrote:
It only spits out an error when the site is in testing or debugging mode, in live mode nothing is displayed…
Thanks, Els. In normal operation, would this write anything to the http error log?
Edit: I’ve found the answer to this :)
Last edited by gaekwad (2009-05-13 21:21:02)
Offline
Re: Is this possible: "if form x exists, output it, otherwise do nothing"
This a related query…I’m using this to include keyword meta data:
<meta name="keywords" content="<txp:if_individual_article><txp:keywords />,</txp:if_individual_article><txp:output_form form="<txp:section />_keywords" />,<txp:output_form form="keywords" />" />
I have a form called ‘keywords’ containing the global keywords (rendering correctly), and the keywords from the individual article (also rendering correctly). Where it falls down is the part in the middle:
<txp:output_form form="<txp:section />_keywords" />
which, when viewing an article in the section ‘articles’, I would expect to output the form ‘articles_keywords”, which does exist and is populated, but is not rendered…the error given in debugging mode is Form not found: _keywords
, so the <txp:section /> is not parsing properly, yet does in the article body. Is <txp:section /> limited to article context only? I couldn’t see any reference to it on the Textbook tag reference.
Offline
#5 2009-05-13 21:24:13
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Is this possible: "if form x exists, output it, otherwise do nothing"
You need to use single quotes when using tags as attribute values:
<txp:output_form form='<txp:section />_keywords' />
Offline
Re: Is this possible: "if form x exists, output it, otherwise do nothing"
Aha! Perfect -thank you very much for your assistance :)
Offline