PDA

View Full Version : how to have category/product names in url


deekstar
07-01-09, 23:09
Hallo guys, Happy new year!
I have decided to look at this last, it perhaps should have been first, but after looking at customisation documents, I still don't know how to put the actual category or product name keywords in the url of the page, for example;

http://www.mydomain.com/category.php?rb=4-4

how do I change the category numbers in this address, to be the actual keywords, in this case Electronics?
and therefore the same for the actual product pages
Sorry for the question, I saw the huge list of category id's in the customisation/bespoke functions guide, it looked simple in the instructions, but I usually get more practical and straight forward answers from you guys
Thanks in advance
Deekstar

CaptainFalcon
08-01-09, 10:15
One way i have seen it done is by adding the product name /category name to the URL and having the category/productID at the end. You will most likely need to take a look at using 'rewrite rules' within your .htaccess file.

For example:
http://www.mydomain.com/category.php?rb=4-4
becomes:
http://www.mydomain.com/category/electronics-4

OR
http://www.shopwindow.com/product.php?p=20124230
becomes
http://www.shopwindow.com/product/sony-ps3-playstation-console-40gb-version-20124230

In the first example, you could even cache the category tree and drop the number off the end.

The second example, add the product number to the end.

Let us know how this goes as this is an interesting topic.

CaptainFalcon
08-01-09, 10:59
Quick followup

I noticed 'mjb328' posted his site earlier.

Take a look at http://www.whostocks.co.uk/ for inspiration.

deekstar
12-01-09, 03:25
Thanks guys for the reply, Iam looking into it further with al options
Cheers Deekstar

mjb238
13-01-09, 11:26
Hey

You'll need to look into using .htaccess to rewrite the URLs. Here's the rule I used for categories:

RewriteRule ^([A-Za-z0-9-]+)-c([0-9-]+)/?$ productlist.php?rb=4-$2

Although you could write a rule for each category and drop the number, or store the categories in a database making sure the category titles are unique.

You then have the hack up the function buildLink in class.shopcore.php to have the category name as well so it can add it to the links.

Hope that helps, and thanks for looking at who stocks! :D

Mike

90numbers.com
27-02-09, 12:45
Hey

You'll need to look into using .htaccess to rewrite the URLs. Here's the rule I used for categories:

RewriteRule ^([A-Za-z0-9-]+)-c([0-9-]+)/?$ productlist.php?rb=4-$2

Although you could write a rule for each category and drop the number, or store the categories in a database making sure the category titles are unique.

You then have the hack up the function buildLink in class.shopcore.php to have the category name as well so it can add it to the links.

Hope that helps, and thanks for looking at who stocks! :D

Mike

Hi Mike,

First of all I love your site very nicely done. I'm equally impressed with your mod-rewrite I don't really know that much but have started reading around. I tried to use the example you gave but cant get it to work. Would it be possible for you to PM me the mod_rewrite element of your .htaccess so I can have a look and hopefully get it to work on my site.

Are there any files that need editing other than .htaccess?

Regards

Pete