Tutorial Override of core / plugins / packages tpl files in certain template

Discussion in 'Subrion Open Source CMS Core' started by Andrew_G., Dec 10, 2015.

  1. Andrew_G.

    Andrew_G. Staff Member

    Greetings to all!

    Today I want to let you know about one of the most useful features of the Subrion CMS - Override f plugins / packages tpl files.

    I) Override of plugins tpl files

    For example, you want to have unique (not default) block.latest_news.tpl file of the News plugin in your template.

    In order to implement this you don't need to edit the ../plugins/news/templates/front/block.latest_news.tpl file (file inside the news plugin), but you need to:
    1) copy the block.latest_news.tpl file from ../plugins/news/templates/front/ folder to the ../templates/YOUR_TEMPLATE/plugins/news/ folder (if you don't have the 'plugins' and 'news' folders inside the YOUR_TEMPLATE folder, please create them)
    2) edit the ../templates/YOUR_TEMPLATE/plugins/news/block.latest_news.tpl file as you need

    I.e. in order to override any plugin tpl file via your template you need to:
    1) copy the needed tpl file from ../plugins/plugin_name/templates/front/ folder to ../templates/YOUR_TEMPLATE/plugins/plugin_name/ folder
    2) edit the needed tpl file that is situated in the ../templates/YOUR_TEMPLATE/plugins/plugin_name/ folder
    II) Override of packages tpl files

    Packages override functionality works in the same way as plugins:
    1) you need to copy the needed tpl file from ../packages/package_name/templates/common/ folder to ../templates/YOUR_TEMPLATE/packages/package_name/ folder
    2) edit the needed tpl file that is situated in the ../templates/YOUR_TEMPLATE/packages/package_name/ folder

    III) Override of tpl files from ../templates/common/ folder

    In order to override tpl file that is placed in the ../templates/common folder you need to:
    1) copy the needed file from the ../templates/common/ folder to the ../templates/YOUR_TEMPLATE/ folder
    2) edit the needed tpl file that is situated in the ../templates/YOUR_TEMPLATE/ folder


    This approach allows you to have all the modified tpl files in one template. So if any plugin /package or ../templates/common/ folder will be updated your changes will be left untouched.

    NOTE. tpl files inside YOUR_TEMPLATE folder have the highest priority, so they will be loaded first.
    So, if you edit tpl file that's in the ../plugins/plugin_name/templates/front/ folder and you have the same file in the ../templates/YOUR_TEMPLATE/plugins/plugin_name/ then file from ../plugins/plugin_name/templates/front/ folder will not be loaded.

    Hope this instruction will be helpful.

    Please ask if you have any questions.
    oglasi, VioletB and Greg like this.

Share This Page