Customizing the SimpleCatalog dashboard

Erstellt am: Donnerstag 18 Mai 2017  |  Letzte Änderung am: Samstag 11 August 2018

SimpleCatalog's dashboard is a simple way to get an overview of the the current item status, it's not yet completely developed and currently without a special use, but it will probably be further expanded and new features are planned for the future SC releases.

The SC dashboard is quite easy customizable, you have control over most of the information displayed there and design of the template can also be changed.

Let's start with extending the dashboard template, that you can change as well as all other SimpleCatalog templates, see more information here: How to use SimpleCatalog templates. The dashboard templates are contained in the admin.php file. You will find this file under the following path: /plugins/im_simple_catalog/tpl/

If you want to extend or change variables contained there, you should create a custom.admin.php file (if you haven't done this yet) in the same directory. Simply copy the admin.php file and name it custom.admin.php. Delete all variables there that should remain unchanged and leave only those you want to edit. SimpleCatalog will load custom.admin.php file at runtime and read it's content, so the entries in original admin.php will be overwritten by custom variables.

Just a simple example, we want to change places for the slider and recent items, the default template looks as follows:

$this->dashboardWrapper =
<<<EOD
    <div class="manager-wrapper dashboard">
        <ul id="info-block">
            <li>[[items_total]] <span>[[it_total_number]]</span></li>
            <li>[[categories_total]] <span>[[ct_total_number]]</span></li>
        </ul>
        [[slider]]
        <h4>[[recent_items]]</h4>
        <div class="recent-items-wrapper">
            [[recent-items]]
        </div>
        <div id="dashb-footer">
            <ul class="dashb-footer-navi">
                <li>Created by: [[creator]]</li>
                <li class="sep">•</li>
                <li>eMail: [[creator_mail]]</li>
                <li class="sep">•</li>
                <li>Phone: [[creator_phone]]</li>
                <li class="sep">•</li>
                <li>More infos: [[infos]]</li>
            </ul>
        </div>
    </div>
EOD;

In order to switch places between slider and recent items, so that the slider is shown below recent items, you will need to replace the associated placeholders:

$this->dashboardWrapper =
<<<EOD
        ...
        <h4>[[recent_items]]</h4>
        <div class="recent-items-wrapper">
            [[recent-items]]
        </div>
        [[slider]]
        ...
EOD;

Okay, that may have been too straightforward an example, next, we want to change the footer text:

Unfortunately, there is no settings variable for change this data, nevertheless it's not a big problem, because we can use the SimpleCatalog's API for this purpose. Using the method getDashboardData(), enables you to access the values displayed there:

$data = $catalog->processor->getDashboardData();

To see what the $data variable contains, do a simple var_dump(), or use ItemManager's Util::preformat() method:

Util::preformat($data);

After you have got the $data, you can assign a new value to Created by on using a statement like this:

$data->createdBy = '<a href="http://whatever.com">Ringo</a>';

To change the email text assign a new value to createrMail:

$data->createrMail = '<a href="mailto:juri.your@email.com">your@email.com</a>';

To change the phone number:

$data->createrPhone = '<a href="tel:+4915267939574">+49 152 67939574</a>';

More infos URL:

$data->helpUrl = '<a href="http://www.your-url.com">Your text coming here</a>';

Use saveDashboardData() method to save the data changes permanently:

$catalog->processor->saveDashboardData();

Autor: Bigin  |  Tags:  FrameworkPHPGetSimpleDevelopmentItemManager