Re: Even prettier URLs tutorial

2006-07-12 Thread Bobby [livin' dead productions]

Graham I liked your tutorial, and I've come up with a little addition
for it.

An excerpt for my work in progress site:

function view ($entry=NULL)
{
$item = $this-News-findBySlug($entry);
if(!empty($item)) {
$this-set('news', $item);
}
elseif ($this-News-find(id = $entry)!=NULL) {
$this-set('news', $this-News-find(id = $entry));
} else { $this-flash('That\'s not a valid news entry.br /No 
such
id or slug exists.', '/news'); }
}

I'm sure you understand the code (and I doubt it's the best way to do
it), but I thought it'd be neat to have both id and slug links.  It may
be a little redundant, but not everything can have a slug.  Also, if a
user bookmarked the page with the id, say before you switched to slugs
or before the particular page had a slug, their link will still work.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Even prettier URLs tutorial

2006-06-20 Thread Graham Bird

Hi,

I've just created a simple tutorial to show how you can use words in
your Cake URLs rather than IDs.

For example, instead of:

/articles/view/23435245

you can have

/articles/view/rantaboutrails

Here it is:

http://www.grahambird.co.uk/cake/tutorials/slugs.php

All feedback is welcome.

Thanks,

Graham


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---