I have a database table called posts that has ‘id, title, slug and content’
I want to automatically fill the slug column with an inflected version of the title that has been entered when creating or editing the post.
So for example if I created a post called: “Welcome to my Blog” the following slug would be saved in the db for that post: “Welcome_to_my_Blog”.
I presume this is something you would do in the controller?
Can anyone help? Thanks
I use the CakeDC Utils plugin, it has a "sluggable" behaviour and you just set the field name of the slug and it will save a slug for you automatically from the
namefield (you can specify another field if you need). Once you’ve dropped it into your plugins folder, here is my setup:Make sure you have a
slugfield in your database.