How do I show or list the categories for my custom modules?

I currently try to create a wiki using custom modules. I want to list all categories and the items they contain. I’ve seen in the documentation, that module_category_list is still greyed out.

So my questions are:

  1. Is the feature still in the making?

  2. Have some of you created a workaround for similiar uses?

Thanks in advance (im new to the community)!

Welcome to Treepl CMS! Liquid components module_tag_list, module_category_list, module_archive are working now. You can find more information here https://treepl.co/cms-features, in 4.7 version release notes.
They are still greyed out in the documentation because these are new components. These components will be marked active shortly. In order to use these components, you need to use the following:

{% component type:“module_category_list”, module:“Blog Post”, parentItemId:“1837” %}

Where:
module:“Blog Post” is your module,
parentItemId is current blog Id,
you can insert these arguments [ layout:""], to control output.

All the components work similarly.

treepl.co (https://treepl.co/cms-features)
Treepl CMS Features for Treepl Partners & CMS Resellers

2 Likes

Hello All,

I’m running into an issue here that I can’t seem to resolve. I have a client who is using the ‘Cleaning’ template, which does not include a blog. No big deal - I have created a new blog and set up the template, but I am having a really difficult time displaying the category list in the blog template. I even tried to use another site that is using the ‘Lawyer’ theme, that does include a blog layout, and included the same code on my client’s site:

<ul class="category-list">
{% capture tpl %}<li><a href="?category=[[category]]">[[category]]</a></li>{% endcapture %}
{% include "/includes/categories.inc", source: "Blog Post" %}
</ul>

I then made sure to copy the categories.inc file to the client’s site who is using the ‘Cleaning’ theme, but I’m not having any luck getting the categories to display. Am I missing something here? If anyone has any ideas/suggestions, I’m all ears. I’ve tried everything I can think of!

Thank you!

  • Ryan

Hi @StudioRTP. Sounds like it should work, but 2 possible things to check:

  1. ensure your include file is at the correct path (/includes/)
  2. do the blog posts actually have any categories assigned, because even though there may be categories present in the CMS, the code will only show categories assigned to the current blog’s posts.

Hello Adam,

Thank you for your response (you always help out, I can’t tell you how much I appreciate it!). I looked over your reply here and verified that the categories.inc file is in fact in the /includes/ directory (screen shot:

And that I’m linking to the correct location in the General Blog Layout:

I also took a screen shot of what is in the categories.inc file (that I borrowed from another working site):

Lastly, I took a screen shot of the sole blog article that is on the site with categories assigned (though missing something like that does sound par for the course for me on a Monday - lol!):

I’m sure you have plenty going on right now, so don’t feel obligated to look this over by any means, but if you do have an opportunity - does is look like I am doing something wrong here? Is it possible I was supposed to make an adjustment to the categories.inc file or the way I call to the file in the General Blog Layout?

I even installed a search bar for just blog posts. I assigned the value=“1932” in the prop_ModuleID hidden field, which is the value I see when I hover over the only blog on the site down in the left-hand bottom corner of the Chrome Browser window. For some reason, I can’t get the blog search to display results as I’d expect either, so I may have two issues here. I searched for a word that I know is in the only blog article on the site: ‘insurance’, and it does take me to the Blog Search Results page, but there aren’t any results even though I know the only blog article on the site uses the work ‘insurance’ a couple of times. Perhaps I did something wrong when creating the blog in the first place?

Again, I know you’re busy - but I appreciate any help you can offer!! Thank you as always!

Try 1528 for the blog search ID.
I’ll look over the rest shortly :slight_smile:

Sorry @StudioRTP. 1534 I think should work for the blog search ID.

Boy, I must have screwed something up here with the blog setup - lol! I took your advice and tried ‘1534’ for the blog search ID (I even tried 1528 just in case) and I’m still sent to the blog search results page, but no results for the keyword ‘insurance’. If it helps, this is the code I have on the blog-search-results page:

<h1 class="h2 center">Search Results</h1>
    {% component source: "Blog Post", layout: "Blog Search List", displayPagination: "true", emptyMessage: "No results found matching your query: [{{request.request_url.params.prop_KeyWords}}].", limit: "5", isSearchResult: "true", type: "module", object:"collection" %}

The site (if it helps) is greenmakesithappen.treepl.co and I stuck the ‘blog’ link (https://greenmakesithappen.treepl.co/blog) under the ‘Extras’ dropdown (for now). This is for a friend of mine (who I’ve known for 30+ years) and it’s not a big rush or anything. However, I’m having this issue on a couple of sites, so I am hoping to find out what I’m doing wrong so I can make a global fix to the other sites I’m working on with a similar issue.

Thank you @Adam.Wilson!!

Ah, I see it now.
At the top of your General Blog Layout put this variable:

{% assign parentItemId = this['Id'] %}

The code you are copying uses the parentItemId variable in the include file (and possibly elsewhere).

I don’t think this will fix the blog search though, so I will run some tests with this…

Also, I’d put a leading / for your include path just to make sure that’s always relative to the root:
image
ie:
{% include "/includes/categories.inc" ... %}

So for the Blog Search, I’m guessing you probably don’t have a Blog Search List layout in your Blog layouts section that the above module is requesting?
Look to the Lawyer template for this layout.

Hello Adam,

Excellent - thank you! I added this:

{% assign parentItemId = this[‘Id’] %}

to the top of the General Blog Layout. I also use the categories sidebar on the ‘Post Detail’ layout. I tried to add the same code to the top of that, but it didn’t seem to work. Do I not understand how the parentItemId variable works? Sorry for my ignorance here, but thank you - it is working on the General Blog Layout (post list) page that I have set up. Now I just have to jump in and do a bit of styling - lol! As a side note, I did have the leading ‘/’ for the include path. I just tried to remove it to see if it would help fix the issue and forgot to add it back in. I just added the leading / back into the General Blog Layout and Post Detail layouts to be safe. Thanks for the catch!

Finally, the Blog Search List layout - you nailed it. I created a new Blog Post Layout called Blog Search List Layout, and copy/pasted the Lawyer theme code into the layout and it worked perfectly.

Thank you so much - I’m getting there. I’m always learning, but every day I feel a little more comfortable in the platform. Plus, it’s always great to learn all of these things that I was never able to do on Adobe BC (either because I didn’t know how and support wasn’t nearly as responsive, or it just couldn’t perform some of the tasks). Appreciate all that you do for the community!

No problem @StudioRTP. Glad it’s mostly working for you now.
On the post detail view we need to get that ID a little differently.
So at the top of your Post Detail layout add these variables:

{% assign parentItemId = this['parentId'] %}
{% assign urlBlog = request.request_url.path | split: "/" %}

The first one’s for the ID the include file needs and the second line is to help construct the URL’s used for the category links.

@Adam.Wilson, you are a magician my friend. Thank you so much. I followed your instruction here and the Post Detail page now properly displays the categories and, crazier yet, I think I may understand why the update and addition was necessary!

I think that covers everything here. Once again, I appreciate your help and time here as I know it’s valuable. I hope this thread can also benefit someone else down the road and someday, as I continue to learn and get the hang of liquid, hopefully I can offer something more to the community as well.

Thank you again for setting your valuable time aside to give me a hand here, and in several other instances. I’m very excited about and committed to Treepl CMS, but the more I learn about the vast capabilities and, more importantly, the contributions and information sharing in the community and with Treepl Support, the better I feel about my decision to consider Treepl CMS for my go-to migration and new-site build platform.

Have a great week!!

2 Likes