Widget doesn't work in dashboard, but works well in other pages

I have a problem with widget. I'm using Ultimate cool theme 2.1.1 (WISB), and I can add widget to dashboard, it appears but doesn't work, althought it works well in profile page, group page... How can I fix it?!

Below is my dashboard.php file in WISB/pages folder.


$user = elgg_get_logged_in_user_entity();


$title = elgg_echo('newsfeed');

$composer = elgg_view('page/elements/composer', array('entity' => $user));

$db_prefix = elgg_get_config('dbprefix');
$activity = elgg_list_river(array(
    'joins' => array("JOIN {$db_prefix}entities object ON object.guid = rv.object_guid"),
    'wheres' => array("
        rv.subject_guid = $user->guid
        OR rv.subject_guid IN (SELECT guid_two FROM {$db_prefix}entity_relationships WHERE guid_one=$user->guid AND relationship='follower')
        OR rv.subject_guid IN (SELECT guid_one FROM {$db_prefix}entity_relationships WHERE guid_two=$user->guid AND relationship='friend')

$options = array();

$page_type = preg_replace('[\W]', '', get_input('page_type', 'all'));
$type = preg_replace('[\W]', '', get_input('type', 'all'));
$subtype = preg_replace('[\W]', '', get_input('subtype', ''));
if ($subtype) {
    $selector = "type=$type&subtype=$subtype";
} else {
    $selector = "type=$type";

if ($type != 'all') {
    $options['type'] = $type;
    if ($subtype) {
        $options['subtype'] = $subtype;

switch ($page_type) {
    case 'mine':
        $title = elgg_echo('river:mine');
        $page_filter = 'mine';
        $options['subject_guid'] = elgg_get_logged_in_user_guid();
    case 'friends':
        $title = elgg_echo('river:friends');
        $page_filter = 'friends';
        $options['relationship_guid'] = elgg_get_logged_in_user_guid();
        $options['relationship'] = 'friend';
        $title = elgg_echo('river:all');
        $page_filter = 'all';

$activity = elgg_list_river($options);
if (!$activity) {
    $activity = elgg_echo('river:none');

$content = elgg_view('core/river/filter', array('selector' => $selector));

//$sidebar = elgg_view('core/river/sidebar');

$params = array(
        'title' => $title,
        'content' =>  $composer . $content . $activity,
        //'sidebar' => $sidebar,
        //'filter_context' => $page_filter,
        'class' => 'elgg-river-layout',

$content = elgg_view_layout('two_sidebar', $params);

echo elgg_view_page($title, $content);

  • Thank alot RvR. I'm looking forward to hearing from you.

  • Thanks for your advides. I'll try it :D

  • Thanks RvR, you made my day. But I still have problems on add gadget to dashboard. On this post they said:

    Now add 'dashboard' context additional in your widgets e.g.

    // add a blog widget on dashboard
     elgg_register_widget_type('blog', elgg_echo('blog'), elgg_echo('blog:widget:description'), 'dashboard');

     And you got more widgets for adding on News feed page.

    But I don't know how and where to put this code? After I try all things in this post, in my dashboard there's only one widget (Group activity) in the "Add widget" menu dropdown. But in other pages, it contents all widget I have actived. You can see the images below:



    So in the widgets folder of dashboard there's only folder group_activity, nothing else: mod\dashboard\views\default\widgets\group_activity. Is it related with my problem?! Can you give me some advices?

  • Ok, I resolved my problem. I add the code below into the file start.php of every widget and it works well.

    // add a widget on dashboard
     elgg_register_widget_type('widget_name', elgg_echo('widget_name'), elgg_echo('widget_description'), 'dashboard');

    Thanks RvR for your helping.

    But I still really don't understand why the widgets appear and work in every page except dashboard, until I add this code above to start.php file?! I think it's really importand for me to continute working with elgg. Can anyone explain about it for me?!