I want's to develop a website in codeigniter framework in which i can access any webpage via slug.
For example just like WordPress and Magento we can access category page by www.sitename.com/category_type/category_detailpage
and also we can access that Category_detail directly just by adding its slug after main URI www.sitename.com/category_detailpage.
So my question is that how i have to design schema of slug table in database if you have any case study Project Code for this Slug Directory in Codeigniter than please let me know as soon as possible.
Thanks in Advance!
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
How to use slug?
Will explain with an example:
URL - http://www.example.com/products/apple-iphone-5S-16GB-brand-new/
1) Assuming you are having a product page and ofcourse product page needs some data from URL to understand which product to display.
2) Before we were querying our database using the id we are getting from the URL. But now we'll do the same thing (querying our database) just replacing id with slug and thats it!
3) Hence adding an additional column in your database named slug. Below will be your updated product database structure (just an example).
I've also answered on slug before. Check if it helps.
How to remove params from url codeigniter
Edit:
For this you have to do below changes -
1) Create below 2 tables
2) config/routes.php
3) models/category_model.php (create new file)
4) controllers/category.php (create new file)
5) views/category_detail.php (create new file)