我在elgg中编写了一个插件,将elgg members
的默认标签更改为成员列表中的热门而非newest
。但有一个问题。当我将默认标签设置为popular
时,newest
标签不再有效。
这是我的start.php
文件:
<?php
elgg_register_event_handler('init', 'system', 'plug_test_init');
function plug_test_init(){
elgg_unregister_page_handler('members');
elgg_register_page_handler('members', 'set_popular_as_default');
}
function set_popular_as_default($page) {
if (empty($page[0])) {
$page[0] = 'popular';
}
if ($page[0] == 'search') {
echo elgg_view_resource('members/search');
} else {
echo elgg_view_resource('members/index', [
'page' => $page[0],
]);
}
return true;
}
答案 0 :(得分:0)
感谢iionly中的elgg community,在this discussion中,使用成员钩子解决了问题:
<?php
elgg_register_event_handler('init', 'system', 'plug_test_init');
function plug_test_init(){
elgg_unregister_plugin_hook_handler('members:config', 'tabs', "members_nav_newest");
elgg_register_plugin_hook_handler('members:config', 'tabs', "my_members_nav_newest");
elgg_unregister_page_handler('members');
elgg_register_page_handler('members', 'set_popular_as_default');
}
function set_popular_as_default($page) {
if (empty($page[0])) {
$page[0] = 'popular';
}
if ($page[0] == 'search') {
echo elgg_view_resource('members/search');
} else {
echo elgg_view_resource('members/index', [
'page' => $page[0],
]);
}
return true;
}
function my_members_nav_newest($hook, $type, $returnvalue, $params) {
$returnvalue['newest'] = array(
'title' => elgg_echo('sort:newest'),
'url' => "members/newest",
);
return $returnvalue;
}