Very often, when developing plugins for Elgg, we also add one or more widgets for any purpose. Some times we need to display exactly the same content of a widget at different section of the site, e.g. in custom_index page.
So there are 2 options:
- Copy/paste the same php code, which is not suggested for obvious reasons
- Get the widget content and display it everywhere else we want in our Elgg website. So with every code change in widget view, the changes will be take place in all sections.
The code we have to use for this case is:
$get_widget = elgg_view_layout('widgets', array (
'title' => 'Give a title',
'content' => elgg_view ( 'widgets/mycustomwidget/content' ),
'show_add_widgets' => false,
In code above, the "mycustomwidget" is name of the widget we want to display it's content.