Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[howto] Code snippet: context-sensitive title without <txp:page_title />
Short version: I wanted a more configurable way of displaying TXP title stuff beyond <txp:page_title />
to display something more SEO-friendly.
i) If it’s the root/homepage, display: Home | Site name
ii) If it’s a section, display: Section name | Site name
iii) If it’s an article, display: Article name | Section name | Site name
Here’s how I did it:
<title>
<txp:if_individual_article><txp:title /> |</txp:if_individual_article>
<txp:if_section name="default">Home |<txp:else /><txp:section /> |</txp:if_section />
<txp:site_name />
</title>
I’m expecting this to be old news to most folks round here, but it might be a small fix that can be applied to an existing template to tighten up the <title>
element of a template, or whatever. Regardless, I hope it’s useful to someone :)
Edit: oh, I just saw the ‘How-tos and Examples’ forum, this is probably best in there. Sorry :(
Last edited by gaekwad (2011-10-20 07:32:57)
Offline
Re: [howto] Code snippet: context-sensitive title without <txp:page_title />
Many thanks for this clear idea. It’s exactly what I was looking for.
I’ll use it very soon.
Cheers !
Last edited by vifort (2010-10-18 07:21:21)
Offline
#3 2010-10-18 12:41:09
- candyman
- Member
- From: Italy
- Registered: 2006-08-08
- Posts: 684
Re: [howto] Code snippet: context-sensitive title without <txp:page_title />
Should be put on txptips.
Offline
#4 2013-06-01 15:51:49
- vickilh
- Member
- Registered: 2007-10-30
- Posts: 96
Re: [howto] Code snippet: context-sensitive title without <txp:page_title />
Just tried this. – For some reason, the article title won’t show up in the title tag?
Offline
#5 2013-06-01 16:54:04
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,310
Re: [howto] Code snippet: context-sensitive title without <txp:page_title />
vickilh wrote:
For some reason, the article title won’t show up in the title tag?
First guess: Are you using article_custom with limit=1?
(article_custom is never in individual article mode even when limited to display one article.)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline