Post category titles and posts display logic
-
Trying to figure out how to display the category title/name in the post display. Seems like it should be something like <h3>[? $post['post_category_title'] ?]</h3> but no variations other than 'post_category_id' seem to work (which just shows the category number).
Also wanting to set up logic to check if there's any posts within a particular category, and if not make the section containing the posts display block not appear on the page. Something like:
<logic:if test="CODE TO CHECK IF THERE'S POSTS IN CATEGORY 3">
templates:section
<p>West End:</p>
<data:postrepeater paging="true" pagingrows="6" templatetype="list" postcategory="3" />
</templates:section>
</logic:if> -
We currently have a tutorial on how to list post-category values. You can check it out here:
Show Categories for a PostThis guide will show you how to display all the categories associated with a post. If you only want to display the primary category, you can use the following code:
\Components\Website\Posts\Categories::getColumn($post['post_category_id'], 'post_category_title')
To check if there are posts in a category, you can use this code:
<logic:if test="$post"> <p>West End:</p> <data:postrepeater paging="true" pagingrows="6" templatetype="list" postcategory="3" /> </logic:if>```