PersonalMode Posted March 5, 2023 Posted March 5, 2023 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"} {{endforeach}} 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 See Sub-categories Thanks
opentype Posted March 5, 2023 Posted March 5, 2023 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.
PersonalMode Posted March 5, 2023 Author Posted March 5, 2023 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> </span> {{if \IPS\Member::loggedIn()->member_id}}</a>{{endif}} </div> <div class="ipsDataItem_main ipsPos_middle"> <h4 class="ipsDataItem_title"> <a href="{$category->url()}">{$category->_title}</a> </h4> {{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> </li> {{endforeach}} </ul> {{endif}} {{if $category->_description}} <div class="ipsDataItem_meta ipsType_richText">{$category->_description|raw}</div> {{endif}} </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> </dl> {{endif}} <!--<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> {{else}} <li class='ipsType_blendLinks'>{lang="byline_nodate" htmlsprintf="$lastPost['author']->link()"}</li> {{endif}} <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> {{else}} <li class='ipsType_light ipsResponsive_showDesktop'>{lang="content_categories_index_no_records" sprintf="\IPS\cms\Databases::load( $category->database_id )->recordWord()"}</li> {{endif}} </ul>--> </li> {{endif}} The information that I hid, disappear on the "Category", but didn't disappear on the "Sub Category"
Solution opentype Posted March 5, 2023 Solution Posted March 5, 2023 (edited) 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 March 5, 2023 by opentype
PersonalMode Posted March 5, 2023 Author Posted March 5, 2023 It was so simple 😆🤪 Thanks a lot @opentype 👌
Recommended Posts