简体   繁体   中英

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

On the front page of a client's site, I'd like to display a few article samples with images and headers. Trouble is, the article object strips out all HTML from the introtext before displaying it in the Articles Category module.

Is there a way to display the module's introtext with all the HTML left in?

In version 3.2 you can bypass the _cleanIntrotext method by setting the introtext display option to "hide".

Create an alternate layout (or override default.php) in /templates/your_template/html/mod_articles_category and change

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

to

<p class="mod-articles-category-introtext">
  <?php echo $item->introtext; ?>
</p>

I modified the lines

$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) : '';

I finally found an answer. Turns out on ~siteroot~/modules/mod_articles_category/helper.php has a _cleanIntrotext function that strips out most html from the introtext. Commenting out the str_replace and strip_tags lines fixed my problem right up.

It's not the greatest way to fix this, as I'll have to remember to reimplement this when I upgrade Joomla.

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.

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