Forum

Thread tagged as: Question, Problem, Configuration

With the data the templates seem to work fine.

I'm trying to take it back to the start and find the error. Quick question, nororally with categories would you just use the one output page say category.php to display your sets and if selected individual categories using perch:categories() and perch:category()?

I thought this originally but then went to separate pages as below.

 <?php perch_categories(array(
                         'set' => perch_get('destinations'),
                        'template' => 'cat-list.html',
      'category' => perch_get('s'),

                    )); 


?>
<?php perch_categories(array(


            'category'   => perch_get('s'),
            'template'   =>'category-single.html',

    'count' => 1,

        )); ?>

If all on one how do you I combine both ?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Could you please describe what you're trying to output?

perch_categories() will output a list of categories. Is that what you want? If so, what are the conditions?

If not, what are you trying to output? What are the conditions?

I'm really trying to help but I've got no idea what the problem is.

Ok I am going to take it back from the beginning to try to help you understand what I am trying to achieve.

I have a list of Activities on my site and detail on each. I used list and detail and perch_custom (These work great)

I have also combined Perch Categories to filter under various 'categories' and have displayed as checkboxes on my template. This works great too.

One of these sets is Destinations and I have listed all the cities as individual categories. So the option exists to select what cities the activity is available in.

What I would like to do is also even the client another route and display a list of all the cities (my set Destinations) and then when the select a category (city) from the set destinations it gives you more info on this category and will then in turn show you what activities match this category.

I have added more fields to the single category page and templates seem to work fine it is just the path from the listing of all categories in the set to a single category.

I sincerely hope this helps make my objectives clearer.

Drew McLellan

Drew McLellan 2638 points
Perch Support

when the select a category (city) from the set destinations it gives you more info on this category

For a URL like

destinations.php?s=bristol

You would use:

perch_category('destinations/'.perch_get('s'));

and will then in turn show you what activities match this category.

Something like:

perch_content_custom('Activities', [
    'category' => 'destinations/'.perch_get('s'),
]);

That makes some sense but can I check where I would include the

perch_category('destinations/'.perch_get('s'));

in my page. Tried so many things now don'y know whether I coming or going.

My category.php <?php perch_categories(array( 'set' => perch_get('destinations'), 'template' => 'cat-list.html', 'category' => perch_get('s'),

                )); 



?>

My destinations.php

<?php perch_categories(array(

        'category'   => perch_get('s'),
        'template'   =>'category-single.html',

'count' => 1,

    )); ?>

Thanks again Drew, appreciate your time and patience.

Drew McLellan

Drew McLellan 2638 points
Perch Support

That makes some sense but can I check where I would include the perch_category('destinations/'.perch_get('s'));

Wherever you want "gives you more info on this category" to appear.

Ok I have that function working, YES!!!!

The category slug now and the category info now match! Thank you very much.

One little thing, I basically replaced the code I had on destinations.php with

perch_category('destinations/'.perch_get('s'));

but my category image and info fields not showing. Layout looks fine though.

Do I need to incorporate the category template into this piece of code or is it default?

Or do I need to pass category fields or template through my list template or output page?

No worries I've got it

<?php

perch_category('destinations/'.perch_get('s').'/', array( 'template' =>'category-single.html' )); ?>

thank you very much for your help, I know it took all day but got there! THANK YOU!!!