Hi there!
I would like to display a widget in a mod page that I've created.
How can I do that? Because, I tried to use display_widget but it seems not working...
Thx!
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.
- Cash@costelloc

Cash - 0 likes
- newtof@newtof

newtof - 0 likes
- Cash@costelloc

Cash - 0 likes
- newtof@newtof

newtof - 0 likes
- Cash@costelloc

Cash - 0 likes
- newtof@newtof

newtof - 0 likes
- Cash@costelloc

Cash - 0 likes
- newtof@newtof

newtof - 0 likes
- newtof@newtof

newtof - 0 likes
- newtof@newtof

newtof - 0 likes
You must log in to post replies.Are you using the widgets layout?
Thx Cash!
I don't know what's widgets layout?
I would like to load a widget in a mod page that I've created...
Layout is determined by http://reference.elgg.org/views_8php.html#9a50c9a0639784e3444c3f2428a5b826
The layouts are listed in /views/default/canvas/layouts
If you are just trying to include a single widget, using display_widget() will work.
Unfortunately, not... By the way, how to know the name of the widget? It's written in the plugin, right? Such as add_widget_type('market',elgg_echo("market:widget"),elgg_echo("market:widget:description")); where 'market' is the widget name?
For example, I tried to put display_widget('market'); according to market plugin, see my code below in index.php:
require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
$user = get_input('username');
$body = display_widget('market');
$title = $user->name;
page_draw($title, $body);
But not working :(
Here is the documentation on display_widget(): http://reference.elgg.org/engine_2lib_2widgets_8php.html#437e48ca1d2faacc4a3587aa83bac65f
It does not take a string as a parameter, but the widget object.
Oh...my mistake, sorry!
But this code still not working:
require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
$user = get_input('username');
$user_guid = $user;
$context = 'market';
$column = 1;
$widget = get_widgets($user_guid, $context, $column);
$body = display_widget($widget);
$title = $user->name;
page_draw($title, $body);
Any idea?
The documentation states that get_widgets gets an array of widgets. Plus, when a widget type is registered, it does not create any widgets. Take a look at the add widget action for how to create a widget.
Can't get what you mean... I've hacked the defaultwidgets plugin in order to have multiple default context widget such as dashboard and profile and I'm trying to add this defaultwidget in a new mod plugin...
I will reengineer profile mod...
Anyway, thx Cash...
Ok, I got it!
Just copy index.php from dashboard code in /dashboard and replace by your context. Now, I would like to do a plugin with that...
Finally, I succeed!
I'm going to package a plugin for you guys ;)