Forum

Thread tagged as: Question, Problem, Configuration

Get current category to list on page

I'm trying to get this category_single.html template....

<h1><perch:category id="catTitle" type="smarttext" label="Title" required="true" /></h1>
    <perch:category id="desc" type="textarea" label="Description" editor="markitup" markdown="true" size="s" />

To list at the top on this category.php page...

<div id="text">
<h1 class="f-fp">This is the Category List page</h1>
        <p><a href="portfolio.php">Products</a></p>
        <?php    
            if (perch_get('cat')) {
              perch_category(perch_get('cat'),array(
                'template'=>'category_single.html'
            ));
            perch_content_custom('Portfolio', array(
              'template' => 'portfolio_listing.html',
              'page'=>'/portfolio.php',
              'category' => perch_get('cat'),
            ));
            } else {
              perch_categories(array(
               'set' => 'Products',
        ));
            }
            ?> 
    </div>

I need it to output the category_single.html from the slug ../category.php?cat=products/demolition/

Currently only the portfolio_listing.html outputs (a list of all the products with the "demotion" category.

David Owen

David Owen 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you get any errors?

I don't get any errors when I load ../category.php?cat=products/demolition/

I get this if I load ../category.php

Debug Message
SELECT setID FROM perch2_category_sets WHERE setSlug='Products' LIMIT 1
SELECT main.* FROM perch2_categories main WHERE 1=1 AND setID=2 ORDER BY catTreePosition ASC
Using template: /templates/categories/category.html

Is this an error?

I can output the content of the default category.html using....

<?php
    if (perch_get('cat')) {
      perch_category(perch_get('cat')
      );
    } else {
      perch_categories();
    }

Can this be modified to use the template here? content/category_single.html

Perhaps it's me. I think category_single.html should be in the categories folder yes?

Drew McLellan

Drew McLellan 2638 points
Perch Support

What debug output do you get on category.php?cat=products/demolition/ ?

My original problem I solved. I'd incorrectly put the template category_single.html in the "content" template folder it should have been in the "categories" template folder so nothing was being output on...

<?php    
            if (perch_get('cat')) {
              perch_category(perch_get('cat'),array(
                'template'=>'category_single.html'
            )); 
etc..

Now this has been corrected.

I was getting this with debug on befroe category.php?cat=products/demolition/

Template file not found: /home/sites//public_html/asf2345/perch/templates/categories/category_single.html