Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
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
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
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
Pages: 1