(Elgg-4.1.6)
I've been trying to edit the Activity menu, to no success. Nothing happens at all whatsoevr.
In my elgg-plugin.php
<?php
return [
'plugin' => [
'name' => 'Plugin Overrides',
'activate_on_install' => true,
],
'hooks' => [
'register' => [
'menu:owner_block' => [
'Elgg\Activity\Menus\OwnerBlock::changeActivityIcon' => [],
],
],
],
];
In Elgg\Activity\Menus\OwnerBlock::changeActivityIcon
<?php
namespace Elgg\Activity\Menus;
class OwnerBlock {
public static function changeActivityIcon(\Elgg\Hook $hook) {
$owner = $hook->getEntityParam();
$items = $hook->getValue();
if ($items->has('activity:owner')) {
$items->get('activity:owner')->setText('OK GO');
}
return $items;
}
}
What could it be that I'm missing?
Thank you all in advance.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Jerome Bakker@jeabakker
Jerome Bakker - 0 likes
- Revilo@Revilo
Revilo - 0 likes
- Jerome Bakker@jeabakker
Jerome Bakker - 0 likes
You must log in to post replies.Have you tried
Is your plugin below the Activity plugin?
Hi there Jerome. I've managed to get it to work by overriding the original menu item and re-registering it all over again. Your solution, however, doesn't do any changes - I'm not sure why. I was hoping it would as my solution doesn't seem like the more clean and consistent way to go about it.
Revilo,
I tried (almost) exactly what you did. And it works.
The only change I made was the namespace of the Class that handles the hook. Since you put your class in exactly the same namespace as the Activity plugin it could be that your plugin overrules the class. Therefor the original item isn't registered.
If you place your the class in namespace 'YourName\YourPlugin\Menus' it should work. The class file should then be place inside you plugin in the folder 'classes\YourName\YourPlugin\Menus\OwnerBlock.php'