Overriding views is a little like forking: you don't get upstream core/plugin changes. In Elgg 1.8+ you can alter views--to do more surgical alterations--after they've been rendered. You do this using the "view" plugin hook.
Example: remove breadcrumbs that have no links
// arguments are 'view', the view name, and your handler callback
elgg_register_plugin_hook_handler('view', 'navigation/breadcrumbs', 'myPlugin_alter_breadcrumbs');
function myPlugin_alter_breadcrumbs($hook, $type, $returnValue, $params) {
// $hook is 'view', $type is the view name, $returnValue is the string
// output of the view, and $params['viewtype'] has the view type.
if ($params['viewtype'] === 'default') {
if (false === strpos($returnValue, '<a ')) {
$returnValue = ''; // if no link, remove completely
}
}
return $returnValue;
}
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.
Another difference to consider: even if another plugin overrides the view, your handler function will still be called. This can be good or bad depending on how that plugin changes the view and how your handler operates.
Thanks for reminding me about this steve, I really under-utilize this plugin hook as it's quite easy to extend or overwrite a view, but this does definitely have some advantages in certain situations.
+1
Haven't used that hook since 1.7