Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-05-19 19:21:51

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

#3 2009-05-19 19:55:20

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

#4 2009-05-19 20:03:19

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

#5 2009-05-19 20:11:26

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

#7 2009-06-09 07:03:46

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Missing article context

Offline

#8 2009-06-09 14:16:23

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: Missing article context

Awesome, thanks! Meanwhile, txp:variable still works great in 4.0.8.

Offline

Board footer

Powered by FluxBB