Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
No title displayed in a page
<code><txp:title /></code> outputs nothing, and <code><txp:page_title /></code> only outputs the site name, when I place either one in a page template’s head section. Debug output offers no clues.
All of the examples seem to put these tags right into a page template, in the <code><title></code> element of the head section. But according to TextBook, <code><txp:title /></code> is “used in an article form”.
What am I doing wrong?
Offline
Re: No title displayed in a page
Hi MichaelZ,
as you said, <txp:title />
is used in an article form.
So, if you put it inside a page template, you wont get anything outputted
What you can do is the following:
1. create an article form and just put an <txp:title />
tag inside. Name it “title”.
2. then, in your page template, call it by using <txp:article form="title" />
Of course, that only make sense in an individual-article context, so I would recommend you to wrap it in some <txp:if_individual_article></txp:if_individual_article>
Something like this
<code><txp:if_individual_article><title><txp:article form=“title” /></title></txp:if_individual_article></code>
Or maybe
<code><title><txp:if_individual_article><txp:article form=“title” /><txp:else /><txp:page_title /></txp:if_individual_article></title></code>
So, if you are in an individual article, it will output the article title (txp:article
calls the “title” form that only has txp:title
inside), and if you are not in individual-article context (so, in an article-list context) you will get the output of txp:page_title
Last edited by maniqui (2006-03-17 19:43:17)
Offline
#3 2006-03-17 19:34:52
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: No title displayed in a page
You will have to turn ‘auto-append comments to articles’ off if you do this, otherwise your comments will show in the head of your page ;)
Offline
Re: No title displayed in a page
Or you could read this for a few ideas and variations.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: No title displayed in a page
Thanks for all the responses. I’m almost there.
I created a form called “title” and filled it with a variation of the SEO suggestion. One important point: it has to be inserted with a limit <code><txp:article form=“title” limit=“1” /></code>, or else an article listing page will have several title elements in the head.
I still have a couple of pages showing no title at all because I used raw PHP code to selectively insert image index or article tags, but I should be able to sort that out.
Offline
Re: No title displayed in a page
MichaelZ wrote:
I created a form called “title” and filled it with a variation of the SEO suggestion. One important point: it has to be inserted with a limit <code><txp:article form=“title” limit=“1” /></code>, or else an article listing page will have several title elements in the head.
Why would you want the title of one particular article in an article-list context?
That’s why I suggested the usf of txp:if_individual_article.
The <title />
of an article in the <title></title>
will make sense for me in an individual-article context.
But in an article-listing context you will get the title fo who knows wich article (of course, this can be controled, I know, even with some <txp:article_custom form="title" id="articleId" />
magic.
But, that’s up to you MichaelZ. You are right about using limit="1"
but how do you decide wich article title do you want to display?
Offline
Re: No title displayed in a page
I’m building a site with a number of sections composed of static pages, some having sub-pages in the section.
The article to be displayed on a section’s top page is selected from the section using a txp:article tag and a custom field for sort order. Section navigation links are created similarly, without the limit=1.
<code><txp:article limit=“1” form=“static_article” sortby=“sortorder” /></code>I’m not sure if this is the best way to do it, but it seems to work, and it should be relatively easy for content editors to add articles to.
Last edited by MichaelZ (2006-03-18 05:43:33)
Offline
Pages: 1