Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Missing article context
I have an article tag like this:
<txp:article status="sticky" form="_meta-keywords" />
…that calls an article-type form with this line in it:
<meta name="Keywords" content="<txp:if_keywords><txp:keywords /><txp:else />my, default, keywords</txp:if_keywords>" />
On pages where no keywords are specified for the sticky article, everything is fine— I see the default keywords I specified in the form.
But on pages where keywords are specified for the sticky article, I get this tag error:
Tag error: <txp:keywords /> -> Textpattern Notice: Article tags cannot be used outside an article context
…and the keywords tag is empty:
<meta name="Keywords" content="" />
I have a form called by the article
tag. What did I do wrong?
Thanks!
Last edited by johnstephens (2009-05-19 19:42:23)
Offline
#2 2009-05-19 19:49:13
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Missing article context
What does the tag trace say?
Offline
Re: Missing article context
Tag trace:
[Form: _meta-keywords]
<txp:if_keywords>
[<txp:if_keywords>: true]
</txp:if_keywords>
[ ~~~ secondpass ~~~ ]
<txp:keywords />
Tag error: <txp:keywords /> -> Textpattern Notice: Article tags cannot be used outside an article context on line 2075
-->
It didn’t seem very informative to me.
Offline
Re: Missing article context
Oddly, if I take out the if_keywords
conditional, the whole error goes away— I get no error if I do it like this:
<meta name="Keywords" content="<txp:keywords />, my, default, keywords" />
…but then I’m always outputting the default keywords regardless of whether they are relevant. This is puzzling. Is this a know error with txp:if_keywords
?
Offline
Re: Missing article context
And this method works without a hitch:
<txp:variable name="has-keywords" value='<txp:keywords />' />
<meta name="Keywords" content="<txp:if_variable name="has-keywords" value="">my, default, keywords<txp:else/><txp:keywords /></txp:if_variable>" />
I think I’ll look up how to report a bug on the txp:if_keywords
tag…
Last edited by johnstephens (2009-05-19 20:11:58)
Offline
#6 2009-05-19 20:30:07
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Missing article context
Hmm… it’s not what I would expect either. Are you viewing the sticky article on an individual article page or on an article list page? If you change the if_keywords and keywords tags to if_custom_field and custom_field, does it work? (just out of curiosity)
Offline
Re: Missing article context
Offline
Re: Missing article context
Awesome, thanks! Meanwhile, txp:variable
still works great in 4.0.8.
Offline
Pages: 1