在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):ericlbarnes/CodeIgniter-Slug-Library开源软件地址(OpenSource Url):https://github.com/ericlbarnes/CodeIgniter-Slug-Library开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):CodeIgniter Slug LibraryThis library is designed to help you generate friendly uri strings for your content stored in the database. For example if you have a blog post table then you would want uri strings such as: mysite.com/post/my-post-title The problem with this is each post needs a unique uri string and this library is designed to handle that for you. So if you add another with the same uri or title it would convert it to: mysite.com/post/my-post-title-2 Requirements
UsageHere is an example setup:Please note that these fields map to your database table fields.
Adding and Editing Records:When creating a uri for adding to the database you will use something like this:
Then for editing: (Notice the create_uri uses the second param to compare against other fields).
Methods__construct($config = array())Setup the library with your config options. $config = array(
'table' => 'mytable',
'id' => 'id',
'field' => 'uri',
'title' => 'title',
'replacement' => 'dash' // Either dash or underscore
);
$this->load->library('slug', $config); set_config($config = array())Pass an array of config vars that will override setup Paramaters
$config = array(
'table' => 'mytable',
'id' => 'id',
'field' => 'uri',
'title' => 'title',
'replacement' => 'dash' // Either dash or underscore
);
$this->slug->set_config($config); create_uri($data = '', $id = '')Creates the actual uri string and in the background validates against the table to ensure it is unique. Paramaters
$data = array(
'title' => 'My Test',
);
$this->slug->create_uri($data) $data = array(
'title' => 'My Test',
);
$this->slug->create_uri($data, 1) This returns a string of the new uri. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论