We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Docs

Categories Support

The content on the Categories page https://docs.grabaperch.com/functions/categories/perch-categories/ is empty. please can you provide content as I have a problem with called the categories and creating links.

Timothy Rackham

Timothy Rackham 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

An example would simply be:

<?php
     perch_categories([
        'set' => 'my-set',
     ]);
?>

So I have built this page ( http://gochattervideos.com/blog/archive.php ) with isotope grid filter. and I wanted to allow the user to post a blog post and select categories and then the filter should link up with this, however when I try to get the categories to come through as a class on the blog posts list they can only display the categories number. and in the filter bar at the bottom it just fails to it all together and I have had to manually enter them in which isn't going to work... Hope that makes sense....

Plus on a post I have the categories printing out and what them to be able to view more in the same, however I can't get the url to print #filter= and then the catergory...

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show us the code that isn't working?

Blog archive listing

<div class="five-col grid-item <perch:blog id="categories" />">
    <a href=" <perch:blog id="postURL" />" rel="bookmark">
        <img class="repson-img" src="<perch:blog id="image" type="image" />" />
    </a>

    <div class="summary">
        <p class="time"> <perch:blog id="time" type="text" textile="true" /> </p>
        <h3> <perch:blog id="postTitle" type="text" textile="true" /> </h3>
        <p> <perch:blog id="excerpt" type="textarea" textile="true" words="20" append="..." /> </p>
    </div>
</div>

Filter bar

<perch:before>
    <div class="button-group filter-button-group">
</perch:before>
    <button class="button <perch:category id='catTitle' />">
        <perch:category id="catTitle" />
    </button>
<perch:after>
    </div>
</perch:after>

I need the blog post add class of the categories in the post and the filter to display each

categories section post template

<perch:categories id="categories" set="blog" label="Categories" display-as="checkboxes">
        <a href="archive.php?#filter=.<perch:category id="catSlug" type="slug" />" class="p-category">
            <perch:category id="catTitle" type="text" />
       </a>
</perch:categories>

Did this help ?

Simon Clay

Simon Clay 127 points

Hi, for your Blog Item Listing first div try:

<div class="five-col grid-item <perch:categories id="categories" set="blog"><perch:category id="catSlug" type="slug" /> </perch:categories>">

And your filter bar:

<perch:categories id="categories" set="blog">
  <perch:before>
    <div class="button-group filter-button-group">
  </perch:before>
      <button class="button <perch:category id='catTitle' />"> <perch:category id="catTitle" /> </button>
  <perch:after>
    </div>
  </perch:after>
</perch:categories>

That won't restrict the number of post for each category and stop duplication tho.

thanks for sharing!

[url=http://www.hoalansaigon.vn/] lan hồ điệp[/url]|[url=http://hoalansaigon.vn/hang-tram-mau-lan-ho-diep-tet-dep-lung-linh.html/ ] Lan ho diep tet [/url] | [url=http://www.axaengineers.com/] Civil Engineering Outsourcing[/url]