Forum

Thread tagged as: Question
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, those both look about right. What problem are we trying to fix?

The initial problem was that clicking a category at the bottom of the detail page of an offer wouldnt make it to the category page however I have sorted that by adding category.php?cat= prior to the cat path.

The problem I am now having is i cant get the rewrite to work correctly. Ideally I would like it to appear as /business/manufacturers/nissan/ instead of /business/category.php?cat=manufacturers/nissan/

Drew McLellan

Drew McLellan 2638 points
Perch Support

In your template, change this:

<li><a href="/business/category.php?cat=<perch:category id="catPath" />"><perch:category id="catTitle" /></a></li>

to this:

<li><a href="/business/category/<perch:category id="catPath" />"><perch:category id="catTitle" /></a></li>

I had tried that previously and tried it again just now but unfortunately it doesnt work. It returns the detail.php page instead of the category.php page without listing any items related to the category.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is your problem with the link or the routing?

The link works in that it points to /business/category/manufacturers/nissan/ but it doesnt return the category page with the list of items associated with that category so I am guessing it is something in the rewriting.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, there's a limit to how much time I can spend helping with things like rewrite rules that are general web development questions rather than issues with the product itself.

I was working on something else and have now realised what has been happening with the rewrite.

I have more than one rewrite running in the same folder of the site.

My previous rewrite setup was

RewriteRule ^business/([a-zA-Z0-9-/]+)$ business/detail.php?s=$1 [L]
RewriteRule ^business/([a-zA-Z0-9-/]+)$ business/category.php?cat=$1 [L]

I have changed this to the following as once you clicked through to the detail.php page of an item it overwrote the category links on the page and didn't display the category page with the listing of items. Instead it was showing the detail.php page when you clicked a category link.

RewriteRule ^business/detail/([a-zA-Z0-9-/]+)$ business/detail.php?s=$1 [L]
RewriteRule ^business/category/([a-zA-Z0-9-/]+)$ business/category.php?cat=$1 [L]

This is now working correctly loading the category page with a listing associated with the selected category.