-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Added plugin event triggers to the new mod_articles module #44132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
cd77ec3
080e763
e86efc0
3280b8a
cbfae96
a5a2329
f85f794
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,8 @@ | |
| use Joomla\CMS\Application\SiteApplication; | ||
| use Joomla\CMS\Component\ComponentHelper; | ||
| use Joomla\CMS\Date\Date; | ||
| use Joomla\CMS\Event\Content; | ||
| use Joomla\CMS\Factory; | ||
| use Joomla\CMS\HTML\Helpers\StringHelper as SpecialStringHelper; | ||
| use Joomla\CMS\HTML\HTMLHelper; | ||
| use Joomla\CMS\Plugin\PluginHelper; | ||
|
|
@@ -238,6 +240,40 @@ public function getArticles(Registry $params, SiteApplication $app) | |
| $item->link = Route::_('index.php?option=com_users&view=login&Itemid=' . $Itemid . '&return=' . $return); | ||
| } | ||
|
|
||
| $item->event = new \stdClass(); | ||
|
|
||
| // Check if we should trigger additional plugin events | ||
| if ($params->get('triggerevents', 0)) { | ||
| $dispatcher = Factory::getApplication()->getDispatcher(); | ||
|
|
||
| // Process the content plugins. | ||
| PluginHelper::importPlugin('content', null, true, $dispatcher); | ||
|
|
||
| $contentEventArguments = [ | ||
| 'context' => 'com_content.article', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was merged with wrong context, what happened? 😄
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding the mod_articles context will not load the custom fields. It needs to go through com_content or else information will be missing. I didn't feel like change plugin events. |
||
| 'subject' => $item, | ||
| 'params' => $item->params, | ||
| ]; | ||
|
|
||
| // Extra content from events | ||
|
|
||
| $contentEvents = [ | ||
| 'afterDisplayTitle' => new Content\AfterTitleEvent('onContentAfterTitle', $contentEventArguments), | ||
| 'beforeDisplayContent' => new Content\BeforeDisplayEvent('onContentBeforeDisplay', $contentEventArguments), | ||
| 'afterDisplayContent' => new Content\AfterDisplayEvent('onContentAfterDisplay', $contentEventArguments), | ||
| ]; | ||
|
|
||
| foreach ($contentEvents as $resultKey => $event) { | ||
| $results = $dispatcher->dispatch($event->getName(), $event)->getArgument('result', []); | ||
|
|
||
| $item->event->{$resultKey} = $results ? trim(implode("\n", $results)) : ''; | ||
| } | ||
| } else { | ||
| $item->event->afterDisplayTitle = ''; | ||
| $item->event->beforeDisplayContent = ''; | ||
| $item->event->afterDisplayContent = ''; | ||
| } | ||
|
|
||
| // Used for styling the active article | ||
| $item->active = $item->id == $active_article_id ? 'active' : ''; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.