How to use SimpleCatalog templates

Erstellt am: Samstag 13 Mai 2017  |  Letzte Änderung am: Dienstag 14 August 2018

You will find all existing SC frontend templates in the frontend.php file, under: /plugins/im_simple_catalog/tpl/ folder. Do not delete or change content of this file - if you have your own templates, or would like to change the existing SimpleCatalog templates, create your own custom.frontend.php file in the same directory. Simply copy the frontend.php file and rename it to custom.frontend.php.

Next, delete all variables you don't want to change and leave only those that you want to edit. SimpleCatalog will load your custom.frontend.php file at runtime and read it's content, so the entries in original file will be overwritten by your data. For example, if you are going to create a new category view in frontend and do not want to show extra infos like description, category_info etc, so you will have to change $this->categoryRow template in custom.frontend.php file as follows.

Here's the default template:

$this->categoryRow =
<<<EOD
<section class="sc-element-wrapper">
    <figure>
        <a href="[[href]]"><img src="[[image]]" alt="[[image_title]]"></a>
    </figure>
    <header><h3>[[name]]</h3></header>
    <div class="sc-element-infos">
        [[description]]
        <div class="sc-element-navi">
            [[category_info]]
        </div>
    </div>
</section>
EOD;

Your template might then look something like this:

$this->categoryRow =
<<<EOD
<section class="sc-element-wrapper">
    <figure>
        <a href="[[href]]"><img src="[[image]]" alt="[[image_title]]"></a>
    </figure>
</section>
EOD;

Well, what if you don't want to show categories page? - It's simple, just create a copy of the $this->categoryListWrapper, here's the default variable

$this->categoryListWrapper =
<<<EOD
<div class="sc-cl-wrapper">
    [[header]]
    [[breadcrumbs]]
    [[content]]
    [[pagination]]
    [[footer]]
</div>
EOD;

... and leave the value empty:

$this->categoryListWrapper = '';

Ok, but what if you're planning to extend your categories or items with custom fields? - Yep, you can do that, just follow the instructions below:

First, create a category in SimpleCatalog, then go to the ItemManager's Fields tab and insert a new field for your category. In order to make the field data visible in frontend, just extend your template variable with a placeholder with the same name as you named the field you have created, for example:

$this->categoryRow =
<<<EOD
<section class="sc-element-wrapper">
    <figure>
        <a href="[[href]]"><img src="[[image]]" alt="[[image_title]]"/></a>
    </figure>
    <header><h3>[[name]]</h3></header>
    <div class="sc-element-infos">
        [[description]]
        [[your_field_name]]
        <div class="sc-element-navi">
            [[category_info]]
        </div>
    </div>
</section>
EOD;

Note, do not delete or change native fields of existing SC categories, it won't work.

Autor: Bigin  |  Tags:  FrameworkPHPGetSimpleDevelopmentItemManager