URL's like : www.something.com/controller/class/function/id/product_title |
[eluser]Unknown[/eluser]
I want to have url's in my codeigniter application like : www.something.com/controller/class/function/id/product_title , where id is any product number which is unique, and the product title is an any combination of albhabets which will be taken from the mysql database by fetching a single unique row. so how can i do that, i searched on net and found nothing useful about it, please help.
[eluser]adityamenon[/eluser]
It looks like ID is the identifier of the product, and codeigniter has nothing to do with the "Product title". In the place you are generating links to your products, fetch a tiny bit of the product title, use str_replace() to get rid of the spaces and put in dashes. Concatenate that with the generated URL. In the controller function that takes care of generating the product page, ignore the "product title" - it will be passed as the second argument. Just make room for it in the function declaration and ignore it afterwards.
[eluser]mr lister[/eluser]
First off, your URL is incorrect - refer to CodeIgniter URLs on how it is constructed. Should be along the lines of: Code: example.com/class/function/id/product_title As adityamenon is alluding too, this is how it could look: Code: <?php You can then query your database using the variables. If, as you mention the 'product id' is unique, it will return a single row if your query is correct. I suggest you have a read of the CodeIgniter User Guide - I found it very helpful and it explains very well what you wish to achieve.
[eluser]vitoco[/eluser]
what you say/want Code: http://www.something.com/controller/class/function/id/product_title Code: http://www.something.com/[folder]/controller/function/[param_1]/[param_1] so in the controller, in order to get the params from the uri Code: function show_product() Also, as CI allows only a limited list of characters in the url, the "product_title" must be passed througth the function Code: url_title() Hope it helps. Saludos |
Welcome Guest, Not a member yet? Register Sign In |