Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-12-17 04:57:14

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

More useful title tag

I have been frustrated for a while due to the inability of textpattern to use the title tag outside of an article form. It seemed like there should be a better way. I just spent some time reverse engineering the code for the page_title tag and I think I have a potential answer.

<code>function title($atts)
{
global $thisarticle, $id;
$out = ($thisarticle) ? $thisarticle[‘title’] : safe_field(‘Title’,‘textpattern’,“ID = $id”);
return escape_title($out);
}</code>

After doing some non-exhaustive testing, this seems to do what I was looking for.

Offline

#2 2005-12-17 16:43:04

ramanan
Plugin Author
From: Toronto
Registered: 2004-03-12
Posts: 323
Website

Re: More useful title tag

Yep, that looks like it should work. (I think you might generating warnings in the case where $thisarticle isn’t initialized however. I can you can turn on error reporting to test. You might want to use the isset function if that is the case.)

Offline

#3 2005-12-18 02:50:08

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

Re: More useful title tag

Ramanan,

As far as I can tell, it works the same way as before.

<code>function title()
{
global $thisarticle, $id;
$out = (isset($thisarticle)) ? $thisarticle[‘title’] : safe_field(‘Title’,‘textpattern’,“ID = $id”);
return escape_title($out);
}</code>

I did some more testing, and I haven’t found a problem yet.

Last edited by michaelkpate (2005-12-18 02:50:22)

Offline

Board footer

Powered by FluxBB