Forum

Thread tagged as: Question, Problem

List/detail URL rewrite issue

I've created a template to be used for multiple list/detail pages. I have it working well with the 'list' page linking to the slug.

<a href="?s=<perch:content id="slug" type="slug" />">

I've setup rewrite rules for SEO friendly URL's which work correctly.

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

The problem I have is the list template is used on multiple pages, how can I work out the page name from within the template? Eg. 'dog-food' or 'cat-food'.

<a href="dog-food/<perch:content id="slug" type="slug" />">

or

<a href="cat-food/<perch:content id="slug" type="slug" />">
Brad Hardinge

Brad Hardinge 0 points

  • 7 years ago

If you're using perch_content_custom to display the content, you can use id="_page". In your case, you probably want _page without the file extension, so you would use something like <perch:content id="_page" replace=".php|" />