0

Using the content event onContentPrepare() within a plugin in the contexts of 'com_contact.category' and 'com_contact.contact' works fine.

But the following code doesn't output anything on a page which is showing the Contacts » Featured Contacts:

public function onContentPrepare($context, &$row, &$params, $page = 0) {
  var_dump($context);
}

If would expect something like e.g. com_contact.featured.

Also onContentBeforeDisplay() and onContentAfterDisplay() doesn't work.

Do i have a chance to get a content-plugin work within alle three events on the featured contact-page?

1

I did some research and found a solution using template overrides (thanks to Sharky answer).

You can manually trigger content plugins in template overrides for featured contacts as well.

Default template

Path: /templates/<template>/html/com_contact/featured/default.php

Run the content plugins on some text:

echo JHtml::_('content.prepare', 'For example mail like mail@domain.de are cloaked.');

Or run content plugins on a custom context like "com_contact.featured":

$featured = new stdClass;
$featured->text = 'For example mail like mail@domain.de are cloaked.'; // add text
$featured->params = new JObject; // add more to parameters if needed
JPluginHelper::importPlugin('content');
JFactory::getApplication()->triggerEvent('onContentPrepare', array ('com_contact.featured', &$item, &$item->params, 0));

Default Items template

Path: /templates/<template>/html/com_contact/featured/default_items.php

Run the content plugins on each item:

$app = JFactory::getApplication();
foreach($this->items as $item) {
  $app->triggerEvent('onContentPrepare', array ('com_contact.contact', &$item, &$item->params, 0));
}

Note that the context 'com_contact.contact' is used.

0

No, plugin events are not triggered on Featured Contacts page. You can request this feature on the Issue Tracker. Until this is implemented in core, you can only manually add the events in layout overrides.

  • Thank you @Sharky. What do you mean exactly with "add the events in layout overrides": Is it possible to trigger events in layout overrides? – sbruemmer Feb 5 at 10:10
  • Yes, it's done with JFactory::getApplication()->triggerEvent(). But doing anything in the layout is for your personal use only. If you want to create a plugin that can be used on other sites, this needs to be implemented in core first. – Sharky Feb 6 at 7:19

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.