Jump to content

Sub-Category Database Templates

Go to solution Solved by opentype,

Recommended Posts

Hi everybody,

Can you help me for this ?

I don't understand how can I change template for a Sub-catagory database.

In the template "Listing" I see

{{foreach $category->children() as $cat}}
				{template="categoryRow" group="category_index" location="database" app="cms" params="$cat"}

Then, the template "Category" is the same for "Sub-Category" ?

But When I change the Category Template, the changes doesn't appear for Sub-category.

Why ?


See Categories

Could contain: File, Text, Nature, Outdoors, Computer, Electronics, Pc, Page


See Sub-categories

Could contain: File, Computer, Electronics, Pc, Webpage, Computer Hardware, Hardware, Monitor, Screen, Text




Link to comment
Share on other sites

Sorry, it’s not clear what you are asking. What change have you made to which template specifically? And where do you expect it to appear?

By the way: Never touch the original templates! Always create custom templates first before making changes. Making changes to the default templates is irreversible and will cause unnecessary problems in the future. 

Link to comment
Share on other sites

Sorry, it's not always easy to express yourself well on technical details in a foreign language.


"Category" template is the same template for "Category" and for "Sub-Category" (Children Category if you prefer)

But When I change something in the template, I can see changes in "Category", but not in "Sub-Category"


Here is my test code. As you can see, I hide the HTML Code for the profil photo and informations about last post.

{{$RecordsClass = $category::$contentItemClass;}}
{{if $category->can('view')}}
{{$lastPost = $category->lastPost();}}
	<li class="ipsDataItem ipsDataItem_responsivePhoto {{if $RecordsClass::containerUnread( $category )}}ipsDataItem_unread{{endif}} ipsClearfix" data-categoryID="{$category->_id}">
		<div class="ipsDataItem_icon ipsDataItem_category">
			{{if \IPS\Member::loggedIn()->member_id}}<a href="{$category->url()->setQueryString( array( 'do' => 'markRead', 'c' => $category->_id ) )->csrf()}" data-action='markAsRead'>{{endif}}
				<span class='ipsItemStatus ipsItemStatus_large {{if !$RecordsClass::containerUnread( $category )}}ipsItemStatus_read{{endif}}'>
					<i class="fa fa-comments"></i>
			{{if \IPS\Member::loggedIn()->member_id}}</a>{{endif}}
		<div class="ipsDataItem_main ipsPos_middle">
			<h4 class="ipsDataItem_title">
				<a href="{$category->url()}">{$category->_title}</a>
			{{if $category->hasChildren()}}
				<ul class="ipsDataItem_subList ipsList_inline">
					{{foreach $category->children() as $subCategory}}
						<li class="{{if $RecordsClass::containerUnread( $subCategory )}}ipsDataItem_unread{{endif}}">
							<a href="{$subCategory->url()}">{$subCategory->_title}</a>
			{{if $category->_description}}
				<div class="ipsDataItem_meta ipsType_richText">{$category->_description|raw}</div>
		{{if $lastPost}}
			<dl class="ipsDataItem_stats ipsDataItem_statsLarge">
				{{$count = $RecordsClass::contentCount( $category, FALSE );}}
				<dt class="ipsDataItem_stats_number">{number="$count"}</dt>
				<dd class="ipsDataItem_stats_type ipsType_light">{expression="\IPS\cms\Databases::load( $category->database_id )->recordWord( $count )"}</dd>
		<!--<ul class="ipsDataItem_lastPoster ipsDataItem_withPhoto">
			{{if $lastPost}}
				<li><div class='ipsType_break ipsContained'><a href="{$lastPost['record_url']}" class='ipsTruncate ipsTruncate_line' title='{$lastPost['record_title']}'>{$lastPost['record_title']}</a></div></li>
                {{if $category->last_poster_anon}}
                <li class='ipsType_blendLinks'>{lang="byline_nodate" htmlsprintf="$lastPost['author']->link( NULL, NULL, TRUE )"}</li>
                <li class='ipsType_blendLinks'>{lang="byline_nodate" htmlsprintf="$lastPost['author']->link()"}</li>
				<li data-short="1 dy" class="ipsType_light"><a href='{$lastPost['record_url']->setQueryString( 'do', 'getLastComment' )}' title='{lang="get_last_post"}' class='ipsType_blendLinks'>{datetime="$lastPost['date']"}</a></li>
				<li class='ipsType_light ipsResponsive_showDesktop'>{lang="content_categories_index_no_records" sprintf="\IPS\cms\Databases::load( $category->database_id )->recordWord()"}</li>


The information that I hid, disappear on the "Category", but didn't disappear on the "Sub Category"

Could contain: Text


Link to comment
Share on other sites

  • Solution

Pay attention to this line in the categoryHeader template of the Listing template group. 

{template="categoryRow" group="category_index" location="database" app="cms" params="$cat"}

The group name, here “category_index” points to the template set that is being used. This can be different from the category template you have chosen for the database. You might need to change that name so it matched the category templates you have customized. 

In general, your process is correct. It just looks like you are pointing to two different categoryRow versions. 

Edited by opentype
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...