0

I have 2 positions and 6 modules for each position. I want to show 1 module of each position in each section. I have the following code:

<div class="section">
    <div class="block">
        <div class="block-content">
            <jdoc:include type="modules" name="module-left" style="raw" />
        </div>
        <div class="block-content">
            <jdoc:include type="modules" name="module-right" style="raw" />
        </div>
    </div>
</div>

The above code shows all the modules, with the problem stacking the 6 modules of each position within a single section.

I have the modules (module1, module2 ...) in the position module-left, and (moduleA, moduleB ...) in the module-right position

I want to show the sections in the following way

<div class="section">
    <div class="block">
        <div class="block-content">
            CONTENT module1
        </div>
        <div class="block-content">
            CONTENT moduleA
        </div>
    </div>
</div>
<div class="section">
    <div class="block">
        <div class="block-content">
            CONTENT module2
        </div>
        <div class="block-content">
            CONTENT moduleB
        </div>
    </div>
</div>

Thank you very much

3

Well from your description I can't figure out for 100% what you trying to accomplish.

But my thoughts is you need to simplify code in index.php (remove "block-cobtent") and move it to html/modules.php.

It is the way to add custom wrapper to any model. Also functions from that file are added to module setting, so you can switch to needed layout easily.


Looking through the code I realized that it can be accomplished with settings also, but it will need to configure each module, and that's not want you want.

What you want is: Add code:

function modChrome_section($module, &$params, &$attribs)
{
    $bootstrapSize = (int) $params->get('bootstrap_size', 0);
    $moduleClass   = $bootstrapSize != 0 ? ' span' . $bootstrapSize : '';
    $headerTag     = htmlspecialchars($params->get('header_tag', 'h3'), ENT_COMPAT, 'UTF-8');
    $headerClass   = htmlspecialchars($params->get('header_class', 'page-header'), ENT_COMPAT, 'UTF-8');

    if ($module->content)
    {
        echo '<div class="section ' . htmlspecialchars($params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8') . $moduleClass . '">';

            if ($module->showtitle)
            {
                echo '<' . $headerTag . ' class="' . $headerClass . '">' . $module->title . '</' . $headerTag . '>';
            }

            echo $module->content;
        echo '</div>';
    }
}

to the end of templates/YOUR_TEMPLATE/html/modules.php.

And change your

<jdoc:include type="modules" name="module-left" style="raw" />

to

<jdoc:include type="modules" name="module-left" style="section" />


And solution that author really needs would be something like

  $mods_left = JModuleHelper::getModules('module-left');
  $mods_right = JModuleHelper::getModules('module-right');
  foreach ($mods_left as $i => $module){
    ?>
    <div class="section">
      <div class="block">
        <div class="block-content">
          <?= JModuleHelper::renderModule($mods_left[$i]) ?>
        </div>
        <div class="block-content">
            <?= JModuleHelper::renderModule($mods_right[$i]) ?>
        </div>
      </div>
    </div>  
    <?php
  }
  • Summary: For each module that is in the module-left and module-right positions, I want the code to start from <div class="section">, so that it loads 2 modules per section (1 module per position). Generating the last piece of code from my initial question. Thanks – Leoalv Apr 5 '17 at 14:16
  • Ok, I added your full solution ) Comment if you have any questions. – Alexandr Apr 5 '17 at 21:04
  • Thanks for your support, in fact the function I use is similar, but still keeps stacking the modules from 1 to 1. What I want is to show 2 modules in the same section. I will write my solution here, maybe it is not correct but it worked for me. Thanks for everything. – Leoalv Apr 5 '17 at 21:30
  • Oh, seems like now I understand. But for this you need to use either another html structure or don't use <jdoc:include > but $modules = JModuleHelper::getModules('your-position') and then you render JModuleHelper::renderModule($module[$i]) – Alexandr Apr 6 '17 at 8:14
  • I've added solution for you – Alexandr Apr 6 '17 at 8:19
0

MY SOLUTION was to create 12 positions (6 left and 6 right) and process the modules with the following code:

<?php for ($i=1; $i < 7 ; $i++) :?>
    <div class="section">
        <div class="block">
            <div class="block-content">
                <jdoc:include type="modules" name="module-left-<?php echo $i;?>" style="curtain" />
            </div>
            <div class="block-content">
                <jdoc:include type="modules" name="module-right-<?php echo $i;?>" style="curtain" />
            </div>
        </div>
    </div>

The idea is create a curtain effect with 2 modules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.