Drupal 6 - Specify URL for CCK Type

Q: How can I arrange for the content type that I created with the CCK to follow a specific path/URL pattern?
A: Specify the Path template in the following settings section - Administer/URL aliases/Automated alias settings/Node path settings

With the Pathauto module installed Drupal will automatically generate nice URLs for the types that you define using the CCK it will generate a path alias using the node name rather than its id. However by default it generates a path like:

www.mywebsite.ie/content/my-content-item

Where my-content-item is automagically generated from the node's name.

But what if you want it to generate a URL like this instead:

www.mywebsite.ie/myitems/my-content-item

Well, to specify how the URL's should be generated for your content type, you might think that you should specify the path on the settings page for your content type - but no, you'd be wrong! Instead you must go to the following Admin page:

Administer/URL aliases

In this settings page, click on the 'Automated alias settings' tab and open up the section called 'Node path settings'. Here path templates can be specified for loads of different content types, and you should see your content type listed here too. Just type in the path that you want and save, for example, to follow the myitems/my-content-item pattern above specify:

myitems/[title-raw]

[title-raw] just tells it to insert the node's 'title' when genearting the path, there are loads of other handy replacement options listed..

And from then on all the new nodes of your type should be generated with this path. If you want your old nodes to follow the new path regime, just edit each one, you don't have to change anything just press save and they will be given a new path.

Stranger
Stranger's picture
thanks

quick and simple :)

Stranger
Stranger's picture
url alias

This is nice but can I use url alias for hand coded links?

Joined: 08/01/2009
User offline. Last seen 1 week 3 days ago.
You can manually specify or

You can manually specify or alter a node's alias when youi create or edit a node. Just go to the'URL path settings' section on the node creation/settings page, uncheck the 'Automatic alias' checkbox and then supply the IRL in the text box below. Hope this helps...

Stranger
Stranger's picture
views

I just don't understand why you can't get to these in views or the node name raw. It just doesn't make any sense to me. So instead because of views you end up with urls like node/5 again. Is there any way around this?

Stranger
Stranger's picture
thank you, this was helpful

thank you, this was helpful

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can use BBCode tags in the text.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Proud member of the:
Irish Internet Association

phone-number.png