Forum

Thread tagged as: Problem, Error

Category List

I need help to sort the category listing of pages. But i get an error (404) when clicking on pages in category link.

category.php

     <?php
      if (perch_get('cat')) {
      //output the category title and description, using default category.html template
      perch_categories(array(
      'set'=>'Destination',
      'filter'=> 'catSlug',
      'match' => 'eq',
      'value' => perch_get('cat')
      ));
        // Output a listing of Destinations in that category
         perch_content_custom('Subpages left content', array(
         'template' => 'subpages/destinations-listing.html',
         'page'=>'/*',
         'category' => 'destination/'.perch_get('cat'),
         'sort'=> 'RevSubDetailspageH1Title',
         'sort-order' => 'ASC'
         )); }
     else { // if no query string, just output a list of categories, displayed as 'tags'
      echo '<h2>The Categories</h2>';
      perch_categories(array(
      'set'=>'Destination',
      'template'=>'category-list.html',
      ));
      }
      ?>

URL pattern Route: category/[slug/slug:catPath] and this is what I get: https://www.bergmedia.co.uk/images/cat.JPG

destinations-listing.html

<perch:before><ul class="pub-listing"></perch:before>
 <li>
 <perch:if exists="RevDetailsPageSliderImg"><a href="<perch:content id="_page" />">
 <img class="main-image fl" src="<perch:content id="RevDetailsPageSliderImg" type="image" width="450" height="215" crop="true" />" alt="<perch:content id="RevDetailsPageSliderImgalt" />" /></a>
 </perch:if>
 <a href="<perch:content id="_page" />"><perch:content id="pubname" type="text" /></a> in <perch:content id="location" /></li>
<perch:after></ul></perch:after>

category-list.html

<perch:before><p>Click on a link to see Destinations in that category.</p>
<ul class=destinations-categories"></perch:before>
<li><a href="/category/<perch:category id="catSlug" />"><perch:category id="catTitle" type="text" /></a></li>
<perch:after></ul><perch:showall></perch:after>

This is the only hurdle I have to get the project moving. Can someone help, Please. Thanks

Edward Johansen

Edward Johansen 0 points

  • 2 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Where's the .JPG coming from?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't see a .JPG on that URL. Could you elaborate?

Drew McLellan said:

I don't see a .JPG on that URL. Could you elaborate?

Misunderstanding. The attached link (https://www.bergmedia.co.uk/images/cat.JPG)is the screengrab from the category page.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Edward,

In the template your link is /category/<perch:category id="catSlug" />, which gets you something like /category/beaches

Your URL pattern is category/[slug/slug:catPath] so it is looking for something like /category/some-slug/another-slug.

Try changing your URL pattern to category/[slug:cat].

Thanks, that is working.

https://happynewyear2019z.com We realize we dream, we dream we know.

We ascend chuckling with the light,

We rests sobbing with the night.