I can change the colour of the first word in my module titles. It can be done by adding a span to the first word of the title.
Below modules.php code works for this OK.
BUT
In Joomla admin when I create a class for Module Class Suffix it is not created for the module in the front end.
Something is missing from module.php to enable Module Class Suffix that is created in Joomla admin
This is the code I have for templates/mytemplate/html/modules.php
<?php
/**
* @package Joomla.Administrator
* @subpackage Templates.protostar
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* This is a file to add template specific chrome to module rendering. To use it you would
* set the style attribute for the given module(s) include in your template to use the style
* for each given modChrome function.
*
* eg. To render a module mod_test in the submenu style, you would use the following include:
* <jdoc:include type="module" name="test" style="submenu" />
*
* This gives template designers ultimate control over how modules are rendered.
*
* NOTICE: All chrome wrapping methods should be named: modChrome_{STYLE} and take the same
* two arguments.
*/
/*
* Module chrome for rendering the module in a submenu
*/
function modChrome_xhtmlwithcolor($module, &$params, &$attribs)
{
$headerLevel = isset($attribs['headerLevel']) ? (int) $attribs['headerLevel'] : 3;
if (!empty ($module->content)) : ?>
<?php if ($module->showtitle) : ?>
<h<?php echo $headerLevel; ?>><?php
$title = $module->title;
$title = split(' ', $title);
$title[0] = '<span>'.$title[0].'</span>';
$title= join(' ', $title);
echo $title;
?></h><?php echo $headerLevel; ?>>
<?php endif; ?>
<?php echo $module->content; ?>
<?php endif;
}
?>
In the index.php template module position I have
<jdoc:include type="modules" name="bottom-1" style="xhtmlwithcolor" />
Can someone help or advise with this problem.
The moduleclass_sfx
is passed in to your modChrome_xhtmlwithcolor ()
as part of the &$params
variable. To use it in your PHP you would use something like this:
htmlspecialchars($params->get('moduleclass_sfx'))
Normally you would tend to wrap your module in a <div>
to package it all up nicely for applying CSS, using DOM manipulation etc.
So you might have:
echo "<div class=\"" . htmlspecialchars($params->get('moduleclass_sfx')) . "\">";
... your code ...
echo "</div>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.