Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-02-17 22:05:40

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,378
Website GitHub Mastodon

Your favorite method for "Writing useful page titles"

Writing useful page titles

I will admit it, I have always dislikes the output of <txp:page_title /> as have others (see example). While there are various methods we have come up with for combating it through native code or plugins, I was just curious to see if there is really cool modern way to do it that I am missing.

From one of my sites (I am not even sure if this will work/is still necessary in 4.0.3.):

<txp:if_individual_article>
<title><txp:mkp_title /> :: <txp:section title="1" /> :: <txp:sitename /></title>
<txp:else />
<txp:if_section name="">
<title><txp:sitename /></title>
<txp:else />
<title><txp:section title="1" /> :: <txp:sitename /></title>
</txp:if_section> 
</txp:if_individual_article>
	function mkp_title() 
	{
		global $thisarticle, $id;

		$out = (isset($thisarticle)) ? $thisarticle['title'] : safe_field('Title','textpattern',"ID = $id");

		return escape_title($out);
	}

Last edited by michaelkpate (2011-02-18 01:44:17)

Offline

#2 2011-02-17 23:34:19

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 975
Website

Re: Your favorite method for "Writing useful page titles"

Michael

Please forgive me if I’m missing something that should be obvious. Why use <txp:mkp_title /> instead of <txp:title /> ?

Mike

Offline

#3 2011-02-17 23:38:33

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 975
Website

Re: Your favorite method for "Writing useful page titles"

Offline

#4 2011-02-18 02:08:32

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,378
Website GitHub Mastodon

Re: Your favorite method for "Writing useful page titles"

maverick wrote:

A nice way to format your <title> using textpattern

Thanks for the link. That is exactly the sort of thing I was looking for, although it is an example of textpattern code stability.

Please forgive me if I’m missing something that should be obvious. Why use <txp:mkp_title /> instead of <txp:title /> ?

Apparently between this November 2005 thread and your December 2006 citation <txp:title /> gained the ability to be used outside an article form. My code sample is from the earlier era. I may have known that at the time, but just never bothered to update the template – which I am working on now.

Last edited by michaelkpate (2011-02-18 02:12:31)

Offline

#5 2011-02-18 03:26:58

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 975
Website

Re: Your favorite method for "Writing useful page titles"

michaelkpate wrote:

Apparently between this November 2005 thread and your December 2006 citation <txp:title /> gained the ability to be used outside an article form.

Ah – that makes sense. I had forgotten all about that issue/thread.

Offline

Board footer

Powered by FluxBB