簡體   English   中英

Joomla 3模塊H3標題跨度

[英]Joomla 3 module h3 title span

我可以更改模塊標題中第一個單詞的顏色。 可以通過在標題的第一個單詞上添加一個跨度來完成。

下面的modules.php代碼適用於此確定。

在Joomla管理員中,當我為模塊類后綴創建一個類時,不會在前端為該模塊創建該類。

module.php缺少一些功能來啟用在Joomla admin中創建的模塊類后綴

這是我對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;
}
?>    

在index.php模板模塊的位置

<jdoc:include type="modules" name="bottom-1" style="xhtmlwithcolor" />

有人可以幫助解決這個問題嗎?

moduleclass_sfx作為&$params變量的一部分傳遞到您的modChrome_xhtmlwithcolor ()中。 要在您的PHP中使用它,您將使用類似以下的內容:

htmlspecialchars($params->get('moduleclass_sfx'))

通常情況下,您傾向於將模塊包裝在<div>以很好地將其打包,以便應用CSS,使用DOM操作等。

所以你可能有:

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