简体   繁体   English

Joomla 3模块H3标题跨度

[英]Joomla 3 module h3 title span

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. 下面的modules.php代码适用于此确定。

BUT

In Joomla admin when I create a class for Module Class Suffix it is not created for the module in the front end. 在Joomla管理员中,当我为模块类后缀创建一个类时,不会在前端为该模块创建该类。

Something is missing from module.php to enable Module Class Suffix that is created in Joomla admin module.php缺少一些功能来启用在Joomla admin中创建的模块类后缀

This is the code I have for templates/mytemplate/html/modules.php 这是我对template / 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 在index.php模板模块的位置

<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. moduleclass_sfx作为&$params变量的一部分传递到您的modChrome_xhtmlwithcolor ()中。 To use it in your PHP you would use something like this: 要在您的PHP中使用它,您将使用类似以下的内容:

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. 通常情况下,您倾向于将模块包装在<div>以很好地将其打包,以便应用CSS,使用DOM操作等。

So you might have: 所以你可能有:

echo "<div class=\"" . htmlspecialchars($params->get('moduleclass_sfx')) . "\">";
... your code ...

echo "</div>";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM