Welcome Guest, Not a member yet? Register   Sign In
Add title for item as suffix in url, only for one controller
#5

You will need to adapt it in your model and set your route for item/detail/(:num)/(:any)...

PHP Code:
protected function setUri($data)
{
    if (isset(
$data['data']['title']))
    {
        
helper('text');

        
$data['data']['uri'] = url_title(strtolower(convert_accented_characters($data['data']['title'])));
    }

    return 
$data;


This enables you to call URL's like the StackOverflow (base_url/questions/(:num)/(:uri_title)).

This is a beforeInsert/beforeUpdate trigger for CodeIgniter 4, one row at a time.

Then you can get the item by primary key and have a SEF uri.
Reply


Messages In This Thread
RE: Add title for item as suffix in url, only for one controller - by natanfelles - 03-14-2018, 06:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB