Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • sukinoz Friend
    #1089235

    Hello,

    note: this is a tutorial based in this [post](https://www.joomlart.com/forums/topic/how-to-add-position-before-content/ by @ninja Lead

    With this tutorial you will have a new joomla module position before content (before a single article, before category heading, etc…) and another position after content (after a single article, after a list of intro articles in category blog view, etc.) in purity III (and maybe in any t3-framework template), both position between the sidebar 1 and sidebar 2. (this is the difference with the other modules)

    (see image attached "the_result.png ) The result

    note: This changes maybe will be lost when you update the template, so backup the files before updating and restore after

    Position before Content (or "mainbody component", as t3-framework call it) will be named: before-component Position after Content (or "mainbody component", as t3-framework call it) will be named: after-component

    Be carefull because there is already a module position called "After Content [after-content]". The module position “after-content” is directly loaded in article detail layout file. In file templates/purity_iii/html/com_content/article/default.php . So, it is not the same, because this position is loaded only in the article detail view.

    So, begin:

    • Open templates/purity_iii/tpls/blocks/mainbody.php file

    Change:

    // detect layout
    if ($sidebar1 && $sidebar2) {
        $this->loadBlock('mainbody/two-sidebar', array('sidebar1' => $sidebar1, 'sidebar2' => $sidebar2));
    } elseif ($sidebar1) {
        $this->loadBlock('mainbody/one-sidebar-left', array('sidebar' => $sidebar1));
    } elseif ($sidebar2) {
        $this->loadBlock('mainbody/one-sidebar-right', array('sidebar' => $sidebar2));
    } else {
        $this->loadBlock('mainbody/no-sidebar');
    }

    To:

    // detect layout
    if ($sidebar1 && $sidebar2) {
        $this->loadBlock('mainbody/two-sidebar', array('sidebar1' => $sidebar1, 'sidebar2' => $sidebar2, 'before-component' => 'before-component', 'after-component' => 'after-component'));
    } elseif ($sidebar1) {
        $this->loadBlock('mainbody/one-sidebar-left', array('sidebar' => $sidebar1, 'before-component' => 'before-component', 'after-component' => 'after-component'));
    } elseif ($sidebar2) {
        $this->loadBlock('mainbody/one-sidebar-right', array('sidebar' => $sidebar2, 'before-component' => 'before-component', 'after-component' => 'after-component'));
    } else {
        $this->loadBlock('mainbody/no-sidebar', array('before-component' => 'before-component', 'after-component' => 'after-component'));
    }

    Now, Purity III has several sidebar options: one sidebar left, one sidebar right, two sidebars, two sidebars left, etc. (see image attached "sidebar_options.png").
    mainbody and sidebar options

    So, you have to edit the block or blocks files your are going to use in your template.

    In this tutorial we are going to do it with the two-sidebar.php, one-sidebar-left and no-sidebar:

    Open templates/purity_iii/tpls/blocks/mainbody/two-sidebar.php file

    Change:

            <!-- MAIN CONTENT  -->
            <div id="t3-content" class="t3-content col-xs-12 col-md-6  col-md-push-3">
                <?php if($this->hasMessage()) : ?>
                <jdoc:include type="message" ></jdoc:include>
                <?php endif ?>
                <jdoc:include type="component" ></jdoc:include>
            </div>
            <!-- //MAIN CONTENT -->

    To:

            <!-- MAIN CONTENT -->
            <div id="t3-content" class="t3-content col-xs-12 col-md-6 col-md-push-3">
                <?php if ($this->countModules('before-component')) : ?>
                    <!-- before-component -->
                        <div class="before-component hidden-xs <?php $this->_c('before-component') ?>">
                        <jdoc:include type="modules" name="<?php $this->_p('before-component') ?>" style="raw" />
                        </div>
                    <!-- //before-component -->
                <?php endif ?>
                <?php if($this->hasMessage()) : ?>
                <jdoc:include type="message" ></jdoc:include>
                <?php endif ?>
                <jdoc:include type="component" ></jdoc:include>
                <?php if ($this->countModules('after-component')) : ?>
                    <!-- after-component -->
                        <div class="after-component hidden-xs <?php $this->_c('after-component') ?>">
                        <jdoc:include type="modules" name="<?php $this->_p('after-component') ?>" style="raw" />
                        </div>
                    <!-- //after-component -->
                <?php endif ?>
            </div>
            <!-- //MAIN CONTENT -->

    Open templates/purity_iii/tpls/blocks/mainbody/one-sidebar-left.php file

    Change:

            <!-- MAIN CONTENT -->
            <div id="t3-content" class="t3-content col-xs-12 col-sm-8 col-sm-push-4 col-md-9 col-md-push-3">
                <?php if($this->hasMessage()) : ?>
                <jdoc:include type="message" ></jdoc:include>
                <?php endif ?>
                <jdoc:include type="component" ></jdoc:include>
            </div>
            <!-- //MAIN CONTENT -->

    To:

            <!-- MAIN CONTENT -->
            <div id="t3-content" class="t3-content col-xs-12 col-sm-8 col-sm-push-4 col-md-9 col-md-push-3">
                <?php if ($this->countModules('before-component')) : ?>
                    <!-- before-component -->
                        <div class="before-component hidden-xs <?php $this->_c('before-component') ?>">
                        <jdoc:include type="modules" name="<?php $this->_p('before-component') ?>" style="raw" />
                        </div>
                    <!-- //before-component -->
                <?php endif ?>
                <?php if($this->hasMessage()) : ?>
                <jdoc:include type="message" ></jdoc:include>
                <?php endif ?>
                <jdoc:include type="component" ></jdoc:include>
                <?php if ($this->countModules('after-component')) : ?>
                    <!-- after-component -->
                        <div class="after-component hidden-xs <?php $this->_c('after-component') ?>">
                        <jdoc:include type="modules" name="<?php $this->_p('after-component') ?>" style="raw" />
                        </div>
                    <!-- //after-component -->
                <?php endif ?>
            </div>
            <!-- //MAIN CONTENT -->

    Open templates/purity_iii/tpls/blocks/mainbody/no-sidebar.php file

    Change:

            <!-- MAIN CONTENT -->
            <div id="t3-content" class="t3-content col-xs-12">
                <?php //if($this->hasMessage()) : ?>
                <jdoc:include type="message" ></jdoc:include>
                <?php //endif ?>
                <jdoc:include type="component" ></jdoc:include>
            </div>
            <!-- //MAIN CONTENT -->

    To:

            <!-- MAIN CONTENT -->
            <div id="t3-content" class="t3-content col-xs-12">
                <?php if ($this->countModules('before-component')) : ?>
                    <!-- before-component -->
                        <div class="before-component hidden-xs <?php $this->_c('before-component') ?>">
                        <jdoc:include type="modules" name="<?php $this->_p('before-component') ?>" style="raw" />
                        </div>
                    <!-- //before-component -->
                <?php endif ?>
                <?php if($this->hasMessage()) : ?>
                <jdoc:include type="message" ></jdoc:include>
                <?php endif ?>
                <jdoc:include type="component" ></jdoc:include>
                <?php if ($this->countModules('after-component')) : ?>
                    <!-- after-component -->
                        <div class="after-component hidden-xs <?php $this->_c('after-component') ?>">
                        <jdoc:include type="modules" name="<?php $this->_p('after-component') ?>" style="raw" />
                        </div>
                    <!-- //after-component -->
                <?php endif ?>
            </div>
            <!-- //MAIN CONTENT -->

    Remember, if your are going to use "two sidebars left" or another one, you should edit it and insert these codes in a similar way as the rest:

                <?php if ($this->countModules('before-component')) : ?>
                    <!-- before-component -->
                        <div class="before-component hidden-xs <?php $this->_c('before-component') ?>">
                        <jdoc:include type="modules" name="<?php $this->_p('before-component') ?>" style="raw" />
                        </div>
                    <!-- //before-component -->
                <?php endif ?>
                <?php if ($this->countModules('after-component')) : ?>
                    <!-- after-component -->
                        <div class="after-component hidden-xs <?php $this->_c('after-component') ?>">
                        <jdoc:include type="modules" name="<?php $this->_p('after-component') ?>" style="raw" />
                        </div>
                    <!-- //after-component -->
                <?php endif ?>

    To the end:

    Open templates/purity_iii/templateDetails.xml file

    Change:

            <position>debug</position>

    To:

            <position>debug</position>
            <position>before-component</position>
            <position>after-component</position>

    Now, you should be able to select the positions created in your Joomla Module Manager.

    Finally, -if you use this tutorial and doesn´t work, please post it. -if you use this tutorial and works ok, please post it too.

    • This topic was modified 6 years, 3 months ago by  sukinoz.
    • This topic was modified 6 years, 3 months ago by  sukinoz.

    1. the_result
    2. sidebars_options
    Saguaros Moderator
    #1089361

    Thanks for your sharing!

    sukinoz Friend
    #1089656

    Note: Hide in extra-small devices is activated, so in phones the modules will disappear.

    you should remove every "hidden-xs" from code to make it visible in phones.

Viewing 3 posts - 1 through 3 (of 3 total)

This topic contains 2 replies, has 2 voices, and was last updated by  sukinoz 6 years, 3 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum