Hello !
How can I put two stacked modules in the same position so that they share 50% of the width each?
I would like to do this with the home-2 position

    carlosdel123 Hello

    Here are basic steps:

    • Create new module position
    • Create new block
    • Add the new block into the layout of template

    Create new module position:
    I think you're known how to create new position in the file: /templates/gk_blank(your template name)/templateDetails.xml
    For example: pos1, pos2

    Create new block:
    Create a new PHP file: /templates/gk_blank/layouts/blocks/2cols.php
    Here are the code to load 2 columns:

    <?php
    use Joomla\CMS\Factory;
    use Joomla\Plugin\System\Gavick\GKTemplate;
    use Joomla\Plugin\System\Gavick\Element\GKMenuElement;
    use Joomla\Plugin\System\Gavick\Element\GKOffcanvasElement;
    use Joomla\Plugin\System\Gavick\Element\GKPresetElement;
    
    // No direct access.
    defined('_JEXEC') or die;
    
    $doc = Factory::getDocument();
    $params = $doc->params;
    
    ?>
    
    <?php if($doc->countModules('pos1') || $doc->countModules('pos2')): ?>
    <div id="gk-2cols" class="gk-2cols bg-warning text-white">
      <div class="container">
        <div class="row">
          <?php if($doc->countModules('pos1')): ?>
          <div class="col-12 col-lg-6 gk-pos1-mod d-none d-lg-block">
            <jdoc:include type="modules" name="pos1" style="none" />
          </div>
          <?php endif; ?>
          
          <?php if($doc->countModules('pos2')): ?>
          <div class="col-12 col-lg-6 gk-pos2-mod d-none d-lg-block">
            <jdoc:include type="modules" name="pos2" style="none" />
          </div>
          <?php endif; ?>
        </div>
      </div>
    </div>
    <?php endif; ?>

    Load this new block into the home layout (or other layout on your site)
    Open the file: /templates/gk_blank/layouts/home.php
    Add this line of code to the section you want:

    <?php echo GKTemplate::renderBlock('2cols') ?>

    Finally, assign module to these new module positions.

    Of course, you will have to customize style for module and this block

    Yes, it works fine, thanks. It just doesn't show up in the mobile version.

      Write a Reply...
      You need to Login to view replies.