Welcome Guest, Not a member yet? Register   Sign In
question about controllers, urls and good practice
#10

[eluser]keld[/eluser]
Thanks a lot for your answers!
I guess I need to be more precise about what I'm trying to achieve.

I'm gonna take the example of a merchant site (so i don't reveal my exact project Wink and the functionality is pretty similar) so I have home page that lists some products, a product page with the details of the product, etc...
Right now my urls to the product page look like mysite.com/controller/product/5/ and i would like to have it look like mysite/product/greenshirt.html for example but I still need to have access to this '5' which is the id of the product in the db.

The 'product' means i'm calling the function product() in my controller which is calling the function getProduct() in my model.

The '5' is the product ID that I'm using to identify which product you've clicked on to view it so in my controller i'm doing this:
Code:
$data['product']=$this->Controller->getProduct($this->uri->segment(3));
to get the id and display the correct one.

The link to the product (from the home page for example) looks like this:
Code:
anchor('controller/product/'.$featured['id'].'/'.url_title($product['name'], 'underscore');
which create a url like mysite.com/controller/product/5/greenshirt.html
(because in config.php i did $config['url_suffix'] = ".html"; for search engine and user friendly urls).
The problem with this is that if somebody types mysite.com/controller/product/123/greenshirt.html they dont get the greenshirt page anymore but whatever id 123 is in the db so that's why i wan to hide this ID from the url.

Any suggestions?


Messages In This Thread
question about controllers, urls and good practice - by El Forum - 01-04-2010, 02:05 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 02:23 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 02:53 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 03:15 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 03:22 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 03:26 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 03:35 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 03:35 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 03:44 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 04:16 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 04:19 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 04:27 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 05:24 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 05:38 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 06:48 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 07:01 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 10:31 PM
question about controllers, urls and good practice - by El Forum - 01-04-2010, 11:27 PM
question about controllers, urls and good practice - by El Forum - 01-05-2010, 10:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB