5

I have some trouble with my module chrome.

If I rename the PHP modules.php in template/protostar/html to XXXmodules.php (or anything else, just to break the link), then all the pages on my website are working. But if I leave modules.php as it is, then some pages* are not accessible and I get a This webpage is not available page. On the page that are working, my custom chrome megarounded is working as it should.

The bug also appears if I delete the content of the modules.php or if I only leave:

defined('_JEXEC') or die('Restricted access');

Because I would like to have all the pages on my website accesible + the custom module , I am digging into the way custom chrome works, but except for the question of creating new custom chrome (which I lready know), I can't find any help.

I am trying to understand how protostar/index.php get the link to modules.php so I have tried to look for modules.php in all the files of the folder template/protostar but couldn't any link. I wonder how this modules.php get retrieved! Any idea?

Thanks a lot for your help!

  • Strangely the pages that don't work are the ones that don't have a module in there HTML loaded via loadposition or module anywhere from NoNumber. In brief, a page needs at the main article to load a module in order to work.

EDIT: here is the content of my modules.php (but I doubt the error come from there as when I empty the content I still have the error, only renaming modules.php solve the error)

<?php
// no direct access
defined('_JEXEC') or die('Restricted access');

?>
<?php
function modChrome_megarounded($module, &$params, &$attribs)
{ ?>
        <div class="megamod module<?php echo $params->get('moduleclass_sfx'); ?>">
            <div class="megabox">
                <div class="megaboxouter">
                    <div class="megaboxinner">
                        <?php if ($module->showtitle != 0) : ?>
                            <h6><?php echo $module->title; ?></h6>
                        <?php endif; ?>
                    <?php echo $module->content; ?>
                    </div>
                </div>
            </div>
        </div>
    <?php
}
?>
  • can you add your modules.php code to the question so we can see if there are any obvious issues? – Craig Oct 9 '14 at 2:09
  • so you mean that you get the bug ("unavailable pages") only when module.php is "activated"? – JinSnow Oct 9 '14 at 9:56
5

So, modules.php is the way templates get to define (override?) chrome styles if you like. You've probably read about them in the Understanding Overrides article on Joomla Doc's

Without any code, I'm guessing you're probably experiencing a bug in your PHP, the only way for you to check that will be to turn on Joomla's Debug mode and set it's Error Reporting to something like "Developer". The reason it's only breaking on some pages is probably because those pages have modules that use specific chrome styles defined in your template/protostar/html/modules.php.

If you add your modules.php code to the question we can probably help. Given that you say your chrome is working but other pages break, it may be a simple issue that's breaking the PHP interpreter as it processes other styles.

When you disable that file (by renaming etc) the bug is avoided and the default system chrome probably takes over.

In a stock, out of the box Joomla 3.x installation you'll find modules.php files in 6 locations. These are split between the /administrator and the front-end:

  1. /administrator/templates/system/html/modules.php
  2. /administrator/templates/isis/html/modules.php
  3. /administrator/templates/hathor/html/modules.php
  4. /templates/system/html/modules.php
  5. /templates/beez3/html/modules.php
  6. /templates/protostar/html/modules.php

If you look at #1 and #4 you'll see they are in templates/system/html and contain the default chrome. For the front-end, these are html5, table, horz, xhtml, rounded and outline.

When Joomla! tries to render a page, and processes a module position in a template, it calls the renderModule($module, $attribs) method in the JModuleHelper class. e.g like this module position in Protostar:

<div id="aside" class="span3">
    <!-- Begin Right Sidebar -->
    <jdoc:include type="modules" name="position-7" style="well" />
    <!-- End Right Sidebar -->
</div>

That method takes the style attribute of the jdoc token and uses that to build the name of the modChrome_???? method/function that is responsible for the specified style. Using this bit of code:

$chromeMethod = 'modChrome_' . $style;

// Apply chrome and render module
if (function_exists($chromeMethod))
{
    $module->style = $attribs['style'];

    ob_start();
    $chromeMethod($module, $params, $attribs);
    $module->content = ob_get_contents();
    ob_end_clean();
}

As you can see if the function exists in the modules.php file of the current template it will then call that method and capture it's output before returning it to the main rendering process.

  • Thanks ccpl. I haven't had the time to check the debug mode but I just want to make something more clear. When modules.php is "activated", then the module chrome works where it is suppose to work. Only pages that don't load module (either in a module position or with the loadmodule code in HTML -for these modules not chrome is applied) don't work. Also if I delete completely the code in modules.php, then the same thing happens (the same pages don't work and of course the moduel chrome doesn't work but any page that load modules in a module position or with loadposition still work). – MagTun Oct 9 '14 at 7:27
  • Ok, that's odd, I can't check right now but it's possible that having an empty module.php will also cause an error because Joomla will try include it then look for a php method… – Craig Oct 9 '14 at 8:09
  • If you want to check you are more than welcome. Please let me now, so I could "activated" the modules.php (I let it disactived because it give error page for some important pages). Also I have added the content of my modules.php in my question – MagTun Oct 9 '14 at 9:37
  • So an empty modules.php works and so does your code, that probably means the error is somewhere else — have you tried turning on debugging and error reporting to see if anything is reported? – Craig Oct 9 '14 at 11:20
  • Sorry, I wasn't clear: an empty modules.php also creates the bug. Only renaming it (which disables it) "solves" the bug. About the debug tool (with modules.php activated): it weird because when I turn the debug on, I can access the pages, when I turn it off I get an "This webpage is not available" error. – MagTun Oct 9 '14 at 15:07

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.