Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-03-03 18:56:51

MixedContent
New Member
Registered: 2012-02-21
Posts: 8

Tag error is displayed for tag in html comment tags, intended?

The message, “Tag error:…Textpattern Notice: Article tags cannot be used outside an article context” is appearing on some pages on my site. A web search shows about a dozen other Textpattern sites with this problem. (Web search for the full message w/o the markup, tag name, or line number).

I understand what the problem is (as explained in faq/271), but at the moment I’m having difficulty locating where it is. The error message includes the name of the tag (txp:title), but not the name of the page template where it occurs. The only location reference I see is “on line 2323”. Line 2323 of what? The page templates I’m using have about 100 lines each, and the style sheets have about 250 lines. How can I convert this “line 2323” into something that helps me troubleshoot?

At the moment I’m working on the “articles” section, which is assigned the page, “section_page”. By inserting unlikely text I’ve determined this is the template being loaded when I ask for that URL (sitename/articles). In that template, the only occurrences of the tag “txp:title” are commented out. Does Textpattern ignore html comment notation when parsing page templates? That would seem strange, and inconvenient.

I’m hoping the community has the critical clues I lack.

(Changed the topic title to describe the actual problem better. -Els)

Last edited by els (2012-03-03 21:32:33)

Offline

#2 2012-03-03 19:19:17

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Tag error is displayed for tag in html comment tags, intended?

Hi, if you view the source code of your page, copy it and paste it in a text editor that can show line numbers, you should be able to see where approximately line 2323 is. Or you can run the page through the validator and view the source (with line numbers) there. Edit: oh forget that, I wasn’t thinking. It won’t show txp tags… doh! 2nd edit…: though it will show you what’s in line 2323.

To test if the notice refers to the code you commented out, you could try and wrap that code in <txp:hide> tags instead of the html comment tags, and see if the notice still occurs.

Last edited by els (2012-03-03 19:21:54)

Offline

#3 2012-03-03 20:35:06

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 595
Website

Re: Tag error is displayed for tag in html comment tags, intended?

The txp:hide trick is great and really should go in the FAQ. Who has the keys?

Offline

#4 2012-03-03 21:11:19

MixedContent
New Member
Registered: 2012-02-21
Posts: 8

Re: Tag error is displayed for tag in html comment tags, intended?

It appears that <txp:hide> is effective, while <!— —> is not. Is this a design decision, that makes something else easier? (I’m assuming someone out there knows, but maybe not.)

And perhaps I should say again that “line 2323” refers to no line in my templates, styles, or resulting pages, because none of them are anywhere near that large. When I did a View Source on the page served up to my browser, the text began with the error message and contained a total of 144 lines.

So the question remains: line 2323 of what? If it’s line 2323 of some intermediate, Textpattern-internal text which is never made available to the site administrator, then that reference functions only as a distraction, and I’d suggest it be replaced with something else, or at least removed.

Anyway, the original problem is solved. Thank you.

Offline

#5 2012-03-03 21:29:47

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Tag error is displayed for tag in html comment tags, intended?

MixedContent wrote:

If it’s line 2323 of some intermediate, Textpattern-internal text which is never made available to the site administrator, then that reference functions only as a distraction, and I’d suggest it be replaced with something else, or at least removed.

No, I don’t think that is the case. The line number has helped me more than once to find the offending tag.

I’m going to move this thread to ‘Developer support’. I really don’t know if this is intended behaviour or not.

Offline

#6 2012-03-03 21:39:53

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Tag error is displayed for tag in html comment tags, intended?

A simple way to jump from the front side immediately into the page template is saving the following code in a form named page_link

<a href="<txp:site_url />textpattern/index.php?event=page&amp;name=<txp:page_url type="page" />" class="dimmed" title="Edit page (<txp:page_url type="page" />)">P</a>

… and putting this tag onto each page somewhere: <txp:output_form name="page_link" />. One click on that front side link then and you’re in the centre of the inferno. (You could also paste the complete link into every page, of course, but for creating new pages the tag is easier to remember. To say nothing of changing anything about the links.)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#7 2012-03-03 22:05:44

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Tag error is displayed for tag in html comment tags, intended?

MixedContent wrote:

Line 2323 of what?

Probably taghandlers.php or a plugin. The line numbers given in error message stacks tend to indicate the execution branches that the code took to reach the point where the error occurred. That way (and this level of info only shows up in Debugging Production Status, btw) you can backtrack through the code to find the point of origin — which will usually be in a plugin or your templates.

From memory, I think in Testing Production Status you only get a single line number thrown back at you, and this is probably the end point of the function that triggered the error. Either way, line numbers only tend to refer to the source code to allow you and/or developers to track down behaviour. It’s not much use to real people :-P

The error message includes the name of the tag (txp:title), but not the name of the page template where it occurs.

Then ignore the (often confusing) reference to line numbers and make the tag your starting point. Although somewhat biased, I can thoroughly recommend the smd_where_used plugin into which typing “txp:title” and hitting enter will swiftly point you to all places that tag is used.

Does Textpattern ignore html comment notation when parsing page templates?

Yes, by design actually. And although it seems odd to people with an HTML background, it becomes incredibly convenient when working on a live site because it allows you to dump the result of tags into the source code without anybody actually seeing the results on-screen. Thus it gives you a nice way to test what tags will show and to trial or debug things behind the scenes on a live site without affecting the user experience (insert arguments against doing that and performing edits on a dev clone or in a hidden site Section here!)

As mentioned by others in the thread, if you actually want Txp to ignore the tags completely, wrap your unneeded content in <txp:hide> tags. 99.58% of the time that’ll do the trick nicely (the remaining 0.42% being if you try and wrap pairs of conditionals or single <txp:else /> tags separately in the hide construct, which occasionally causes the parser to weep a little).

Hope some of that helps and demystifies things a tad.

Last edited by Bloke (2012-03-03 22:09:08)


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

#8 2012-03-03 22:29:11

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Tag error is displayed for tag in html comment tags, intended?

Bloke wrote:

The line numbers given in error message stacks tend to indicate the execution branches that the code took to reach the point where the error occurred.

Really? In that case my memory played tricks on me (which BTW is quite normal behaviour…). @MixedContent, please ignore my reply above.

uli wrote:

A simple way to jump from the front side immediately into the page template

Nice tip! Just hoping others don’t have the txp:title tag in a zillion forms, like me… ;)

Offline

#9 2012-03-03 22:40:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Tag error is displayed for tag in html comment tags, intended?

Els wrote:

Really? In that case my memory played tricks on me

Hmm, you got me thinking now. Perhaps we’re both right! Certainly the line number of the code is present in the backtrace in Debugging mode. But maybe the further down (uhhh, up :-s) the trace you go, the line numbers start referring to the line numbers in the Pages/Forms (more likely) or raw HTML output (less likely). I honestly can’t remember.

I’d like to say that’s because I’m so superhuman that my pages don’t generate errors any more, but that’d be a lie. Truth is I’m just so used to seeing the error messages during development that I gloss over the fluff and jump straight to the bits of it I need. I’ll pay closer attention to the next one I see and try to get a definitive answer on the subject.


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

#10 2012-03-04 00:29:39

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Tag error is displayed for tag in html comment tags, intended?

Els wrote:

Nice tip! Just hoping others don’t have the txp:title tag in a zillion forms, like me… ;)

Then it’s likely that these tags are not causing that much trouble, I think ;)
If you have several article tags as containers on your page, e.g., you can use the output_form tag several times on your page but as a container as well: <txp:output_form name="page_link">#book-details</txp:output_form> and put a yield tag as the last element of the URL inside the page_link form above. The page opens, you copy the hashtag from the addressbar and paste it in the browser’s search field. Voilà :)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#11 2012-03-04 01:22:08

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Tag error is displayed for tag in html comment tags, intended?

@Stef, please don’t bother. I probably got it wrong.

@Uli, not necessarily in article forms ;) But I really like your tips, never thought of that.

Offline

#12 2012-03-04 04:41:47

MixedContent
New Member
Registered: 2012-02-21
Posts: 8

Re: Tag error is displayed for tag in html comment tags, intended?

“The error message includes the name of the tag (txp:title), but not the name of the page template where it occurs.”

Then ignore the (often confusing) reference to line numbers and make the tag your starting point.

Well, I did. Except that I didn’t yet know that the reported line number was a snare and a delusion.

With all due respect, why issue a message about a configuration problem if the misconfigurator will almost certainly have no clue how to make use of it? Surely the Textpattern engine, some aspect of it anyway, is in a position to know where the out-of-context-tag-reference error was made, and could report both the line number and the name of the file that line is in. (The ancient gcc does it…)

I know, I know, this is just philosphy. I understand that currently Textpattern doesn’t report this information, and I will act accordingly in the future (i.e., i will ignore the line number part of the message).

Also, the tips mentioned here may help a lot in future troubleshooting. Is there a central place where tips like this can be found (or should be found)? E.g., the “page_link” and smd_where_used tips.

Offline

Board footer

Powered by FluxBB