Posted 12 ноября, 20186 yr comment_152892 Добрый день уважаемые пользователи сайта. Интересует одна вещь, существует такая страничка с документацией на офф. сайте, а именно как сделать так, чтобы в левом блоке отображало все категории и подкатегории? То есть глубиной от 1 до 5 к примеру подкатегорий?
12 ноября, 20186 yr Author comment_152894 accop ага, вот шаблон {{$recordClass = null;}} {{$catClass = null;}} {{if count($records)}} {{$recordClass = get_class($records[0]);}} {{$catClass = '\IPS\cms\Categories' . $recordClass::database()->_id;}} {{endif}} {{$firstRecord = null;}} {{$currentUrlPath = \IPS\Request::i()->url()->data['path'];}} {{if count($records) and $catClass and count($catClass::roots())}} <ul class="ipsList_reset cDevDocs" data-controller="devDocs.front.devDocs.main"> {{foreach $catClass::roots() as $root}} <li> <h2>{$root->_title}</h2> {{if count($root->children())}} <ul class="ipsList_reset"> {{foreach $root->children() as $child}} <li class="cDevDocs_closed"> <h3 data-action="expandSection">{$child->_title}</h3> {{foreach $records as $record}} {{if $record->container()->_id == $child->_id}} <ul class="ipsList_reset"> {{if $firstRecord == null}} {{$firstRecord = $record;}} {{endif}} <li> <a {{if $currentUrlPath === $record->url()->data['path']}}class="cDevDocs_active"{{endif}} href="{$record->url()}"> {{if $record->customFieldDisplayByKey('shortened_title', 'raw')}}{$record->customFieldDisplayByKey('shortened_title', 'raw')}{{else}}{$record->_title}{{endif}} </a> </li> </ul> {{endif}} {{endforeach}} </li> {{endforeach}} </ul> {{endif}} <ul class="ipsList_reset"> {{foreach $records as $record}} {{if $record->container()->_id == $root->_id}} {{if $firstRecord == null}} {{$firstRecord = $record;}} {{endif}} <li> <a {{if $currentUrlPath === $record->url()->data['path']}}class="cDevDocs_active"{{endif}} href="{$record->url()}"> {{if $record->customFieldDisplayByKey('shortened_title', 'raw')}}{$record->customFieldDisplayByKey('shortened_title', 'raw')}{{else}}{$record->_title}{{endif}} </a> </li> {{endif}} {{endforeach}} </ul> </li> {{endforeach}} </ul> {{endif}} {{if $recordClass and \IPS\cms\Pages\Page::$currentPage and (string) \IPS\cms\Pages\Page::$currentPage->url() == (string) \IPS\Request::i()->url()}} {{if $firstRecord}} {{\IPS\Output::i()->redirect($firstRecord->url(), '', 302);}} {{else}} {{\IPS\Output::i()->redirect(\IPS\Http\Url::internal(''), '', 302);}} {{endif}} {{endif}}
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.