Creating a new position in the template through a plugin.

Discussion in 'Subrion CMS Templates' started by olairmarcos, Sep 14, 2015.

  1. olairmarcos

    olairmarcos Member

    Hello, I'm planning a new plugin and need to create a new position within the template using the hooks feature to insert new special blocks in the template.
    How can I do to create a new position within any template, setting through install.xml file in the plugin?
    Thank you for help, wait.
  2. Andrew_G.

    Andrew_G. Staff Member

    Greetings @olairmarcos ,

    First of all you need to know that there is no way to create new template position via plugin.

    So you can only paste the code directly to the hook of your plugin's install.xml file.
    For example, you can add the following code (taken from Eu Cookie Policy banner plugin) to ../plugins/YOUR_PLUGIN/install.xml file -> Hooks section:
    Code (Text):
    <hook name="smartyFrontAfterHeadSection" type="smarty">
                <![CDATA[
    {ia_print_css files="_IA_URL_plugins/eu_cookie/templates/front/css/divascookies, _IA_URL_plugins/eu_cookie/templates/front/css/divascookies_style_{$config.eu_cookie_theme}_{$config.eu_cookie_position}"}
    {ia_print_js files="_IA_URL_plugins/eu_cookie/js/frontend/jquery.divascookies-0.3.min"}
    {ia_add_js}
    $(function()
    {
        $.DivasCookies({
            bannerText: '{$config.eu_cookie_text}',
            acceptButtonText: '{$config.eu_cookie_btntext}',
            cookiePolicyLink: '{$smarty.const.IA_URL}policy/',
            cookiePolicyLinkText: '{$config.eu_cookie_policylinktext}',
            openEffect: '{$config.eu_cookie_openeffect}',
            openEffectDuration: {$config.eu_cookie_openeffectduration},
            openEffectEasing: '{$config.eu_cookie_openeffecteasing}',
            closeEffect: '{$config.eu_cookie_closeeffect}',
            closeEffectDuration: {$config.eu_cookie_closeeffectduration},
            closeEffectEasing: '{$config.eu_cookie_closeeffecteasing}'
        });
    });
    {/ia_add_js}
                ]]>
    </hook>
    This hook will add block with cookie policy banner to the top of your site.

    p.s. You can find the list of hooks by enabling the Debug mod -> Hooks section. Please look at attached screenshot file to better understand it.

    Thanks for your interest in our software products!

    Attached Files:

  3. Vasily_B.

    Vasily_B. Project Manager

    Well, thanks Andrew for the explanation. But in general you don't explain the reason why there is no way to add positions through a plugin installation.

    Position requires changes in template files directly, so their code should be modified to display positions from database. So it's more a task for templates to take care of positions they provide.

    If you wish to have the code in a plugin specific template, there is no need to create position then, you can directly hardcode it - that's it. The template can only be used when a plugin is activated.

    Cheers
  4. olairmarcos

    olairmarcos Member

    In version 4.1 will it be possible to create new positions in the template through the installation of a plugin?
    Thanks.
  5. Gleb_S.

    Gleb_S. Subrion Designer Staff Member

    Hi @olairmarcos !

    It is possible to create new position through plugin with SQL instructions, but you will need to add this position to layout.tpl of your template manually.

    Thanks.
  6. olairmarcos

    olairmarcos Member

    Thanks for the answer @Gleb_S. !
    My idea is to add new positions in the template through the existing hooks. This way I will keep the default Quickstart template.
    Thanks.

Share This Page