Can someone give a quick fix to remove the all tab from the activity page.I am using version 1.8.0.1
@Steve The views has changed a little bit in elgg 1.8, for instance, part of the code of the nav.php is in root/pages/river
The part of the code that's there is the one that let you choose which tab is going to be the default one.
If I were to find the correct view where the tabs are being generated I could extend the view. Probably, I don't know lol
@steve :Thnanks Steve your help would be really appriciated
yeah I too browsed through several files of river but was not able to figure out where the view is being generated. :P
I figured out how to do it but it seems the file I need to edit to get it done is engine/lib/river.php and I can seem to override that file.
Haven't really studied the code, but my first guess would be to try and unregister the menu item.
if (elgg_get_context() == 'activity') {
elgg_unregister_menu_item('filter', 'all');
}
I conclude this based on the html code:
<ul class="elgg-menu elgg-menu-filter elgg-menu-hz elgg-menu-filter-default"><!-- developers:begin navigation/menu/elements/item --><li class="elgg-menu-item-all elgg-state-selected"><a href="http://localhost/hypetest18/activity/all" title="" confirm="">All</a></li><!-- developers:end navigation/menu/elements/item --><!-- developers:begin navigation/menu/elements/item --><li class="elgg-menu-item-mine"><a href="http://localhost/hypetest18/activity/owner/ismayil.khayredinov" title="" confirm="">Mine</a></li><!-- developers:end navigation/menu/elements/item --><!-- developers:begin navigation/menu/elements/item --><li class="elgg-menu-item-friend"><a href="http://localhost/hypetest18/activity/friends/ismayil.khayredinov" title="" confirm="">Friends</a></li><!-- developers:end navigation/menu/elements/item --></ul>
ul.elgg-menu-filter
li.elgg-menu-item-all
@Ismayil Khayredinov Great piece of code! I have that same from html code, I will study the code next week I think, I am tied up with a lot of stuffs I need to do hehe
Change root/pages/river.php to this:
<?php
/**
* Main activity stream list page
*/
$options = array();
$page_type = preg_replace('[\W]', '', get_input('page_type', 'friends'));
$type = preg_replace('[\W]', '', get_input('type', 'friends'));
$active_section =
$subtype = preg_replace('[\W]', '', get_input('subtype', ''));
if ($subtype) {
$selector = "type=$type&subtype=$subtype";
} else {
$selector = "type=$type";
}
if ($type != 'friends') {
$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();
break;
case 'friends':
$title = elgg_echo('river:friends');
$page_filter = 'friends';
$options['relationship_guid'] = elgg_get_logged_in_user_guid();
$options['relationship'] = 'friend';
break;
default:
$title = elgg_echo('river:friends');
$page_filter = 'friends';
$options['relationship_guid'] = elgg_get_logged_in_user_guid();
$options['relationship'] = 'friend';
break;
}
$activity = elgg_list_river($options);
$content = elgg_view('core/river/filter', array('selector' => $selector));
$sidebar = elgg_view('core/river/sidebar');
$params = array(
'content' => $content . $activity,
'sidebar' => $sidebar,
'filter_context' => $page_filter,
'class' => 'elgg-river-layout',
);
$body = elgg_view_layout('content', $params);
echo elgg_view_page($title, $body);
@ib Right, like I said, I can do that, it is overriding the core instead of editing the core I am trying to do.
@Ismayil Thanks I will work on that
Ibrahim Hasan Actually that is not going to accomplish our goal here. Overriding core files is not recommended. That is a bad trick, 'cause actually what I want to code is only to show two tabs, not three.
@Steve Keep us updated! Let's do this! haha
@steve Better than overriding core, you could override views/default/page/layouts/content/filter.php
And ad some kind of conditional to the tabs loop,
if ($name == 'all' && (elgg_get_context() == 'activity'))
continue;
Ibrahim Hasan code worked but it still shows the All tab. and other thing is that we should not chage the elgg core codes as Steve said. and the reason behind that is when we upgrade to newer version we need to rechange all the codes........ and Steve :) please do this soon I need this plugin :( and thanks for sharing everything with us :)
@mnrtrq @gillie, There are a few files to call that will override the tabs and I have it working except the override to engine/lib/river.php or to pages/river.php. I am trying a page handler in start.php with no luck.
It will have the all tab for the admin, just as it does in Private_River for 1.7
For see only the admin all tab, and user the friends tab:
<?php
/**
* Main activity stream list page
*/
if (elgg_is_admin_logged_in()) {
$options = array();
$page_type = preg_replace('[\W]', '', get_input('page_type', 'all'));
$type = preg_replace('[\W]', '', get_input('type', 'all'));
$active_section =
$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();
break;
case 'friends':
$title = elgg_echo('river:friends');
$page_filter = 'friends';
$options['relationship_guid'] = elgg_get_logged_in_user_guid();
$options['relationship'] = 'friend';
break;
default:
$title = elgg_echo('river:all');
$page_filter = 'all';
break;
}
$activity = elgg_list_river($options);
$content = elgg_view('core/river/filter', array('selector' => $selector));
$sidebar = elgg_view('core/river/sidebar');
$params = array(
'content' => $content . $activity,
'sidebar' => $sidebar,
'filter_context' => $page_filter,
'class' => 'elgg-river-layout',
);
$body = elgg_view_layout('content', $params);
echo elgg_view_page($title, $body);
} else {
$options = array();
$page_type = preg_replace('[\W]', '', get_input('page_type', 'friends'));
$type = preg_replace('[\W]', '', get_input('type', 'friends'));
$active_section =
$subtype = preg_replace('[\W]', '', get_input('subtype', ''));
if ($subtype) {
$selector = "type=$type&subtype=$subtype";
} else {
$selector = "type=$type";
}
if ($type != 'friends') {
$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();
break;
case 'friends':
$title = elgg_echo('river:friends');
$page_filter = 'friends';
$options['relationship_guid'] = elgg_get_logged_in_user_guid();
$options['relationship'] = 'friend';
break;
default:
$title = elgg_echo('river:friends');
$page_filter = 'friends';
$options['relationship_guid'] = elgg_get_logged_in_user_guid();
$options['relationship'] = 'friend';
break;
}
$activity = elgg_list_river($options);
$content = elgg_view('core/river/filter', array('selector' => $selector));
$sidebar = elgg_view('core/river/sidebar');
$params = array(
'content' => $content . $activity,
'sidebar' => $sidebar,
'filter_context' => $page_filter,
'class' => 'elgg-river-layout',
);
$body = elgg_view_layout('content', $params);
echo elgg_view_page($title, $body); }
@Oranyero, Thanks but like I said in the above posts, I am trying to workout the override of the page handlers, the rest of it works just fine.
Steve
Just talked to Steve, and he seems to have accomplished the task ;)