Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-12-15 13:17:04

Morgon
Member
From: Selmer, Tennessee
Registered: 2004-12-01
Posts: 23
Website

Can you "dirify" titles and names for URLs?

MT has an attribute that I found very handy for creating templates: dirify. I’m sure most everybody knows what this does, but a quick explanation. It takes the value of the tag it is applied to, and converts the string to a URL-safe version:

“My Crazy-Go-Nuts Day!” turns into “my_crazy_go_nuts_day”

Is there any way (plugin or otherwise) to do this in TXP?

Offline

#2 2005-12-15 13:48:24

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

Re: Can you "dirify" titles and names for URLs?

There is a function built into to textpattern that does this. I’m not sure if it is available as a plugin/textpattern tag. What do you want to accomplish? (I am guessing it is something that doesn’t require you to use dirify directly, but you never know.) For example, url titles are automagically dirified, same with category names when used in links, etc.

Offline

#3 2005-12-15 14:57:44

Morgon
Member
From: Selmer, Tennessee
Registered: 2004-12-01
Posts: 23
Website

Re: Can you "dirify" titles and names for URLs?

ramanan, I’ve just moved from MovableType, and this is how I’ve included an image thumbnail, splash image, and possibly banner for each article into my templates. (Not just a thumb and image, no, I’ve gotta go with 3-4 different sizes! :/ )

<code><img src=”/img/<MTEntryTitle dirify=“1”>/thumb.jpg” /></code>

It worked well, and was automatic. I just had to make sure that there were images named “thumb.jpg” and “splash.jpg” in a folder named after the entry title (but dirified).

I can do something like this in Textpattern by using a custom field called “thumbnail_url”, and <code><img src=”<txp:custom_field name=“thumbnail_url” />” /></code>, but then whoever’s adding the entry needs to know the URL (which some of my authors most probably don’t know how to spell URL). I’d prefer (if I can’t use txp’s backend to assign those mulitple images, preferrably in their own directory- not the root “/image”, to the article) to just create all the images for the article, stick it in a folder and upload it via FTP to the /img directory.

Offline

#4 2005-12-15 16:12:08

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

Re: Can you "dirify" titles and names for URLs?

I’m not sure if I understand exactly what it is you want to do, but there is the url-only title (in the write screen, under advanced options). There is no tag to call it, but you can easily create one.

Offline

#5 2005-12-15 22:12:52

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: Can you "dirify" titles and names for URLs?

If you want to associate images with articles, you’d be better off using the Article Image feature.

For a quick hack, <txp:php>global $thisarticle; echo $thisarticle['url_title'];</txp:php> ought to do the trick.


Alex

Offline

#6 2005-12-15 22:43:42

Morgon
Member
From: Selmer, Tennessee
Registered: 2004-12-01
Posts: 23
Website

Re: Can you "dirify" titles and names for URLs?

doggiez:

having virtually no PHP experience except for the odd include here and there, how would I wrap that code you posted and make a plugin out of it?

Offline

#7 2005-12-15 22:56:19

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

Re: Can you "dirify" titles and names for URLs?

Well, there is the plugin template, but I’ve never been able to figure out how it works :(
You might also have a look at Mary’s upm_tags.

Offline

Board footer

Powered by FluxBB