如何在文章类别模块中获得Joomla文章的完整HTML简介?


How do I get the full HTML introtext of a Joomla article in the Articles Category module?

在客户网站的首页上,我想显示一些带有图像和标题的文章示例。问题是,在文章类别模块中显示文章之前,文章对象会从导语中删除所有HTML。

是否有一种方法来显示模块的内文与所有的HTML留在?

在3.2版本中,您可以通过将introtext显示选项设置为"hide"来绕过_cleanIntrotext方法。

在/templates/your_template/html/mod_articles_category中创建一个替代布局(或重写default.php)并更改

<?php if ($params->get('show_introtext')) :?>
  <p class="mod-articles-category-introtext">
    <?php echo $item->displayIntrotext; ?>
  </p>
<?php endif; ?>

<p class="mod-articles-category-introtext">
  <?php echo $item->introtext; ?>
</p>
我终于找到了答案。事实证明,在~siteroot~/modules/mod_articles_category/helper.php上有一个_cleanIntrotext函数,从导言文本中剔除大部分html。注释掉str_replacestrip_tags行解决了我的问题。

这不是解决这个问题的最好方法,因为当我升级Joomla时,我将不得不记住重新实现这个

我修改了这些行

$item->fulltext = $item->introtext;
$item->introtext = self::_cleanIntrotext($item->introtext);
and use fulltext for html an introtext for only text.
$item->displayIntrotext = $show_introtext ? self::truncate($item->introtext, $introtext_limit) : '';
$item->displayFulltext = $show_introtext ? self::truncate($item->fulltext, $introtext_limit) : '';

复制该模块并重命名。注释掉或删除在helper.php中的_cleanIntrotext, str_replace和strip_tags行。您必须将原始模块名称的所有文件和实例替换为新模块名称。为重命名的类添加CSS。可能看起来很复杂,但逻辑思维在大约一个小时左右的时间里就为我解决了这个问题。因为它现在是一个第三方模块,它不会被Joomla!更新。