• Hi folks, all downloads on this site are FREE, you don't even have to sign up. Registration is only required for requests in the support forum. Have fun!
Documentation like IPS

Documentation like IPS 1.0.0

1. Import the database
2. Edit database and change key to "docs"
3. Create a page for the database
4. Create a block for the sidebar
Code:
{{$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 cDocs" data-controller="docs.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="cDocs_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="cDocs_active"{{endif}} href="{$record->url()}">
                            {{if $record->customFieldDisplayByKey('docs-short', 'raw')}}{$record->customFieldDisplayByKey('docs-short', '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="cDocs_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}}
Back
Top