Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2007-01-07 12:03:16

Ace of Dubs
Member
Registered: 2006-04-17
Posts: 446

Re: URL-only title

Mary,

I agree with the others that this should be a standard tag in the core.
I find this indispensible not only for neat CSS tricks but also when I need to add class hooks for javascript stuff on the fly..

<h2 class=”<txp:url-title />”><txp:title /></h2>
<p class=”<txp:url-title />”>Text that is toggled by clicking on the title.</p>

Up till now I been using TXP globals with PHP like so…

<txp:php>echo $GLOBALS[‘thisarticle’][‘url_title’];</txp:php>

But from now on I will just use the hack propsed by Els

Offline

#14 2007-01-07 23:28:10

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: URL-only title

jawtab: Ignore my previous post if you read it, for some reason I was thinking yours was the first post in a separate thread.

Ace: it already was added, to crockery.

Offline

#15 2007-03-20 09:08:29

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: URL-only title

Els wrote:

If you add this
<code>
function url_title($atts)
{
global $thisarticle;
return $thisarticle[‘url_title’];
}
</code>
to taghandlers.php, you’ve got a tag <code><txp:url_title /></code>.
[Edit] You can also make it into a plugin, if you don’t want to have to modify that file every time you upgrade.

This is a really useful hack for me – especially when building custom URLs in sections, but I just tried it in 4.04 for the first time and Els’ warning was well-founded… seems it doesn’t work with this version. Does anyone know how to fix it?

many thanks
Stu

Offline

#16 2007-03-20 15:56:38

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: URL-only title

It still works for me in 4.0.4. Make sure you don’t copy the code from my previous post, because the quotes got textiled. Use this:

function url_title($atts)
{
global $thisarticle;
return $thisarticle['url_title'];
}

Offline

#17 2007-03-20 16:09:07

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: URL-only title

indeed it does – should have spotted that this morning!
cheers Els

Offline

#18 2011-01-30 21:24:45

chad
Member
Registered: 2006-08-06
Posts: 12

Re: URL-only title

To all the people like me, finding this thread belatedly, this tag is now official:

<txp:article_url_title />

Offline

#19 2011-01-30 23:03:24

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: URL-only title

chad wrote:

this tag is now official:

now = since July 2007 ;)

Offline

Board footer

Powered by FluxBB