jimie VIP
Total posts: 531
18 Sep 2015 14:26

Hello Sergey,

Can you tell me how can this file:

views/record/tmpl/default.php

can be override per section or type ?

For example I'd like to change the content of that file to be different per section or type

Rgds

Last Modified: 12 Oct 2015


pepperstreet VIP
Total posts: 3,837
20 Sep 2015 00:54

Hello jimie,
I assume the file itself can only have one override in your template/HTML/... folder.

Inside the default.php you can get the type# or section# of the current item:

$item = $this->item;
$sectionid = $item->section_id;
$typeid = $item->type_id;

Then use the respective variable for an IF ELSE or SWITCH structure.
Or use the variable value to build sub-template name to load a specific record template. etc.

Example SWITCH to check your section ID, and load a different code block:

switch ($sectionid) {
    case "1":
        echo "Your code block here, if section is 1.";
        break;
    case "2":
        echo "Your code block here, if section is 2.";
        break;
    case "99":
        echo "Your code block here, if section is 99.";
        break;
    default:
        echo "Your Code block here, if section is NOT 1, 2, 99!";
}

Same principle applies to type. Just replace $sectionid with $typeid and your numbers...


Jeff VIP
Total posts: 745
20 Sep 2015 01:33

+1

Powered by Cobalt