How to display widget content in to other non-widget file in elgg

144 Views Asked by At
I want to display widget content into non-widget view file.
    but that procedure i don't know.
    pls. help me, get me some extension or information about that.
    in Elgg.

will get code from liked_content Plugin file is elgg.2.2.1\mod\liked_content\views\default\widgets\liked_con‌​tent\content.php

and

paste this code in to

elgg.2.2.1\mod\profile\views\default\profile\owner_block.php

Some, Changes I have Do... Now

                 $widget = $vars['entity'];                            
                 $container = $widget->getContainerEntity();    // problem here                     
                 $options =eligo_get_display_entities_options($widget); // and, problem is here                          
                $options['annotation_names'] = array('likes');

                if (elgg_instanceof($container, 'user') && $widget->my_likes !== 0) {
                  $options['annotation_owner_guids'] = $container->guid;
                }

                if (!elgg_instanceof($container, 'user') && !elgg_instanceof($container, 'group')) {
                  unset($options['container_guids']);
                }


                if ($widget->eligo_sortby == 'mostliked') {
                  $dbprefix = elgg_get_config('dbprefix');
                  $likes_metastring = get_metastring_id('likes');
                  $options['selects'] = array("(SELECT count(distinct l.id) FROM {$dbprefix}annotations l WHERE l.name_id = $likes_metastring AND l.entity_guid = e.guid) AS likes");

                  $options['order_by'] = 'likes ASC';
                  if ($widget->eligo_sortby_dir == 'desc') {
                    $options['order_by'] = 'likes DESC';
                  }
                }

                $content = elgg_list_entities_from_annotations($options);
2

There are 2 best solutions below

3
AddWeb Solution Pvt Ltd On

Yes, you can display it anywhere you would like with the help of function dynamic_sidebar() (i.e. https://codex.wordpress.org/Function_Reference/dynamic_sidebar)

dynamic_sidebar('your-widget-id');
1
nlybe On

In Elgg each widget is also a view. So you can use the line below

elgg_view('widgets\liked_con‌​tent\content');

But in this case you should take care to load the right your params

An alternative way is the following

echo elgg_view_layout('widgets', array (
'title' => 'Give a title',
'content' => elgg_view ( 'widgets/mycustomwidget/content' ),
'show_add_widgets' => false,
));

The "mycustomwidget" is name of the widget we want to display it's content.