Title Of My Posts As Url?

Hello all.

I am building a new site for my project, and I will be filling it will all the content from the current site. I simply need the new URL’s to fit my current site’s URL’s, so I won’t have to redirect everything.

I need the URL’s to look like this: www.domain.com/this-is-my-topic .

Can this be done? The URL has to fit the title of the post, in the exact way as shown above.

Yes, this is possible

check ext

http://www.yiiframework.com/extension/seourlmanager

http://www.yiiframework.com/extension/slug-behavior

http://www.yiiframework.com/extension/yiibehaviorsluggable

http://www.yiiframework.com/extension/urlrouter

Thanks

Thank you so much! I will have a look at this.

I’ve come a little further now. The URL looks right now, but it needs to happen automatically, so it creates the URL’s dynamically, when you write a new post. How can I do this?

There is also a section of the website, that needs a word in the URL, som it looks like this: www.domain.com/artists/this-is-an-artist . It’s the same URL-construction, just with the word added. Can it be done?

Thanks in advance.

Yes it can be done, start researching and find the solution.

I’ve been looking around quite a bit, but can’t seem to find the right solution.

I would really appreciate being pushed in the right direction.

Have a database table called artist, in it have a field for artist name and one for slug, call it slug/nice_url/seo_url/etc.

When you add a artist, say Artist Name, generate the slug/nice_url/seo_url based on the artist name and save it in your table, so you’d have artist_name = Artist name, slug=artist-name

Next, create a ArtistController, with a index action like:




public function actionIndex($slug)

{

   $model=Artist::model()->findByAttributes(array('slug'=>$slug));

   [...]

}



Next, add url rules for this.




'artists/<slug:([a-zA-Z0-9\-])>' => 'artist/index'



And that’s it.

Wow, this sounds promising. I will give it a try, thanks!