0

I've created a template override for the article view where the intro and the full text are invoked separately.

So, instead of

<div itemprop="articleBody">
        <?php echo $this->item->text; ?>
    </div>

I'm using

<div class="intro_text"><?php echo $this->item->introtext;?></div>
        <div class="full_text"><?php echo $this->item->fulltext . JHTML::_('content.prepare'); ?></div>

The inclusion of JHTML::_('content.prepare') doesn't change anything.

Interestingly, content plugins load normally if explicit commands in curly brackets are not required. However, when {command} is required to load a plugin, said {command} is displayed as-is (raw and unprocessed).

1

You are invoking content.prepare without parameters. One of those parameters is the text you want the plug-ins to process. So your code runs the content plug-ins and then appends an empty string to the output.

I think this is the refence you want https://docs.joomla.org/Triggering_content_plugins_in_your_extension.

2
  • Actually, the plugin is not triggered at all. That is to say, the command is displayed raw, as if it were plain text. On the other hand, something like <?php echo $this->item->introtext . '{loadposition Position-1}' . $this->item->fulltext; ?> wouldn't do it ether because the command must be manually added by the users to certain individual articles. Thanks for helping!
    – manchine
    Oct 19 '17 at 19:46
  • Following code did the trick: <?php $fulltext = $this->item->fulltext; $fulltext_prepped = JHtml::_('content.prepare', $fulltext); ?> <div class="intro_text"><?php echo $this->item->introtext;?></div> <div class="full_text"><?php echo $fulltext_prepped; ?></div>.
    – manchine
    Oct 19 '17 at 21:15
1

If you just need plugins to run on the fulltext there is another way that may work for anyone else with this issue: go to the Article settings in the admin console and turn off the "Show Intro Text" setting. Then you can use this code:

<div class="intro_text"><?php echo $this->item->introtext;?></div>
<div class="full_text"><?php echo $this->item->text; ?></div>

(Note: above uses text and not fulltext)

The content in the $this->item->text property will be passed through the plugins but you can still display introtext separately without it being duplicated. It's slightly better this way because you're not running all the plugins twice (once on text and then again when you call content.prepare on fulltext)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.