0

I have a Problem with the carousel module from bootstrapjoomla.com Unfortunately the module doesn't support alternative layouts. But I need to have two carousel on my homepage. Therefore I've to create an override for the carousel where I change the carousel-id.

I tried to create an html-override depending on the moduleclass suffix but it doesn't work. The moduleclass suffix of my second carousel is " Carousel-carousel2". The code I inserted in the default.php in the override:

<?php
defined('_JEXEC') or die;
/* Layout anhand einer CSS-Klasse im Modul umleiten */

if(preg_match('/\Carousel-([A-Za-z]+)/', $module->moduleclass_sfx , $matches)){
 if(!empty($matches[1])){
  $this->setLayout($matches[1]);#ist Layout carousel2
   echo $this->loadTemplate('default'); #carousel2_default.php wird aufgerufen
  }
}else{ 

... 

} ?> 

carousel2_default.php is the file with my override.

My problem is, that the second carousel doesn't use the override but uses the default.php.

  • I solved the problem with insertign an field in the module woth the parameter "modulecarousel_id" and reinstalled it so now I can give each carousel it's own id. – lukasg Jun 22 '15 at 12:48
  • 1
    Please write this as a proper answer below and mark it as "accepted" so people can easily see it has been solved ;) – Lodder Jun 22 '15 at 16:03
1

You can easily add the advanced module options that allow alternative layouts, by creating an override of the modules .xml and adding the advanced fields options within the <fields name="params"> tags, like this:

<config>
    <fields name="params">
        <fieldset name="advanced">
            <field
                name="layout"
                type="modulelayout"
                label="JFIELD_ALT_LAYOUT_LABEL"
                description="JFIELD_ALT_MODULE_LAYOUT_DESC" />
            <field
                name="moduleclass_sfx"
                type="text"
                label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
                description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC" />
            </fieldset>
    </fields>
</config>

This adds the options for alternative layouts and custom module class suffix to the module settings, under the advanced tab, so you can select your alternative layout.

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.