News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Logout as a last button

Started by Realinfo, January 17, 2012, 09:58:15 PM

Previous topic - Next topic

Realinfo

I want to make Logout as a last button............ due to Menu Management buttons, it's not a last button............... how we can make it as last..............

$buttons = array(
'home' => array(
'title' => $txt['home'],
'href' => $modSettings['sp_portal_mode'] == 3 && empty($context['disable_sp']) ? $modSettings['sp_standalone_url'] : $scripturl,
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),
'forum' => array(
'title' => empty($txt['sp-forum']) ? 'Forum' : $txt['sp-forum'],
'href' => $scripturl . ($modSettings['sp_portal_mode'] == 1 && empty($context['disable_sp']) ? '?action=forum' : ''),
'show' => in_array($modSettings['sp_portal_mode'], array(1, 3)) && empty($context['disable_sp']),
'sub_buttons' => array(
),
// This is where help use to be!!!

),
'pages' => array(
'title' => !empty($modSettings['dozen_pages_tab_label']) ? $modSettings['dozen_pages_tab_label'] : $txt['dozen_pages_tab_default'],
'href' => $scripturl . '?action=pages',
'show' => $user_info['is_guest'] ? !empty($modSettings['dozen_pages_enable_guest_access']) : !empty($modSettings['dozen_pages_enable_member_access']),
'sub_buttons' => array(
),
),
'search' => array(
'title' => $txt['search'],
'href' => $scripturl . '?action=search',
'show' => $context['allow_search'],
'sub_buttons' => array(
),
),
'admin' => array(
'title' => $txt['admin'],
'href' => $scripturl . '?action=admin',
'show' => $context['allow_admin'],
'sub_buttons' => array(
'featuresettings' => array(
'title' => $txt['modSettings_title'],
'href' => $scripturl . '?action=admin;area=featuresettings',
'show' => allowedTo('admin_forum'),
),
'packages' => array(
'title' => $txt['package'],
'href' => $scripturl . '?action=admin;area=packages',
'show' => allowedTo('admin_forum'),
),
'errorlog' => array(
'title' => $txt['errlog'],
'href' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc',
'show' => allowedTo('admin_forum') && !empty($modSettings['enableErrorLogging']),
),
'permissions' => array(
'title' => $txt['edit_permissions'],
'href' => $scripturl . '?action=admin;area=permissions',
'show' => allowedTo('manage_permissions'),
),
'portal' => array(
'title' => $txt['sp-adminCatTitle'],
'href' => $scripturl . '?action=admin;area=portalconfig',
'show' => allowedTo(array('sp_admin', 'sp_manage_settings')),
'is_last' => true,
),
),
),
'moderate' => array(
'title' => $txt['moderate'],
'href' => $scripturl . '?action=moderate',
'show' => $context['allow_moderation_center'],
'sub_buttons' => array(
'modlog' => array(
'title' => $txt['modlog_view'],
'href' => $scripturl . '?action=moderate;area=modlog',
'show' => !empty($modSettings['modlog_enabled']) && !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
),
'poststopics' => array(
'title' => $txt['mc_unapproved_poststopics'],
'href' => $scripturl . '?action=moderate;area=postmod;sa=posts',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'attachments' => array(
'title' => $txt['mc_unapproved_attachments'],
'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?action=moderate;area=reports',
'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
'is_last' => true,
),
),
),
'profile' => array(
'title' => $txt['profile'],
'href' => $scripturl . '?action=profile',
'show' => $context['allow_edit_profile'],
'sub_buttons' => array(
'summary' => array(
'title' => $txt['summary'],
'href' => $scripturl . '?action=profile',
'show' => true,
),
'account' => array(
'title' => $txt['account'],
'href' => $scripturl . '?action=profile;area=account',
'show' => allowedTo(array('profile_identity_any', 'profile_identity_own', 'manage_membergroups')),
),
'profile' => array(
'title' => $txt['forumprofile'],
'href' => $scripturl . '?action=profile;area=forumprofile',
'show' => allowedTo(array('profile_extra_any', 'profile_extra_own')),
'is_last' => true,
),
),
),
'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
'is_last' => true,
),
),
),
'todayspost' => array(
'title' => $txt['todays_posts'],
'href' => $scripturl . '?action=todayspost',
'show' => $context['view_todays_posts'],
'sub_buttons' => array(
),
), 'calendar' => array(
'title' => $txt['calendar'],
'href' => $scripturl . '?action=calendar',
'show' => $context['allow_calendar'],
'sub_buttons' => array(
'view' => array(
'title' => $txt['calendar_menu'],
'href' => $scripturl . '?action=calendar',
'show' => allowedTo('calendar_post'),
),
'post' => array(
'title' => $txt['calendar_post_event'],
'href' => $scripturl . '?action=calendar;sa=post',
'show' => allowedTo('calendar_post'),
'is_last' => true,
),
),
),

'chat' => array(
'title' => $txt['chat'],
'href' => $scripturl . '?action=chat',
'show' => true,
'sub_buttons' => array(
),
),

// [Articles] button
'articles' => array(
'title' => $txt['smfarticles_menu'],
'href' => $scripturl . '?action=articles',
'show' => $context['allow_view_smfarticles'],
'icon' => '',
),

// [Staff] button
'staff' => array(
'title' => $txt['smfstaff_stafflist'],
'href' => $scripturl . '?action=staff',
'show' => $context['allow_view_stafflist'],
'icon' => '',
),

// [SMF Gallery] button
'gallery' => array(
'title' => $txt['smfgallery_menu'],
'href' => $scripturl . '?action=gallery',
'show' => $context['allow_smfgallery_view'],
'icon' => '',
),
'mlist' => array(
'title' => $txt['members_title'],
'href' => $scripturl . '?action=mlist',
'show' => $context['allow_memberlist'],
'sub_buttons' => array(
'mlist_view' => array(
'title' => $txt['mlist_menu_view'],
'href' => $scripturl . '?action=mlist',
'show' => true,
),
'mlist_search' => array(
'title' => $txt['mlist_search'],
'href' => $scripturl . '?action=mlist;sa=search',
'show' => true,
'is_last' => true,
),
),
),
'buddylist' => array(
'title' => $txt['buddylist'],
'href' => $scripturl . '?action=buddylist',
'show' => !empty($modSettings['enable_buddylist']) && !$user_info['is_guest'],
'sub_buttons' => array(
),
),
'tagged' => array(
'title' => $txt['googletagged'],
'href' => $scripturl . '?action=tagged',
'show' => allowedTo('googletagged_view'),
'sub_buttons' => array(
),
),
'contact' => array(
'title' => !empty($modSettings['contact_form_tab_label']) ? $modSettings['contact_form_tab_label'] : $txt['contact_form_default_tab_label'],
'href' => $scripturl . '?action=contact',
'show' => $user_info['is_guest'] ? !empty($modSettings['contact_form_enable_guest_access']) : !empty($modSettings['contact_form_enable_member_access']),
'sub_buttons' => array(
),
),

'smfsocialnetwork' => array(
'title' => $modSettings['smfsn_label'],
'href' => $scripturl . '?action=smfsocialnetwork;sa=home',
'show' => allowedTo('smfsocialnetwork_access'),
'sub_buttons' => array(
'smfsocialnetwork_home' => array(
'title' => $modSettings['smfsn_label'],
'href' => $scripturl . '?action=smfsocialnetwork;sa=home',
'show' => true,
),
'smfsocialnetwork_add_link' => array(
'title' => $modSettings['smfsn_label_add_link'] . ' ' . $txt['smfsocialnetwork_label_add_link'],
'href' => $scripturl . '?action=smfsocialnetwork;sa=shareit' . (!empty($pageURL) ? ';url=' . rawurlencode(str_replace(';', '%smfsn3B', $pageURL)) : ';url'),
'show' => !$user_info['is_guest'] && $modSettings['smfsn_show_share_it'],
),
),
),
'login' => array(
'title' => $txt['login'],
'href' => $scripturl . '?action=login',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
),

'register' => array(
'title' => $txt['register'],
'href' => $scripturl . '?action=register',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
'logout' => array(
'title' => $txt['logout'],
'href' => $scripturl . '?action=logout;%1$s=%2$s',
'show' => !$user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
);

// Allow editing menu buttons easily.
call_integration_hook('integrate_menu_buttons', array(&$buttons));


/** start x-Links **/
if(isset($context['xlinks'])) {
$last_button_idx = 'logout';
foreach($context['xlinks'] as $button_idx => $button)
{
$last_button_idx = $button_idx+1;
$_href_injection = $button['href'];
if (!empty($button['style'])) {
$_href_injection .= '" style="'.$button['style'];
}
if (!empty($button['title'])) {
$_href_injection .= '" title="'.$button['title'];
}
if (!empty($button['in_new'])) {
$_href_injection .= '" target="_blank';
}
$last_button_idx = (!empty($button['title']) ? $button['title'] : '').'" name="xlinks'.$button_idx;
$buttons[$last_button_idx] = array(
'title' => $button['name'],
'href' => $_href_injection,
'show' => true,
);
}
$buttons['logout']['is_last'] = false;
$buttons[$last_button_idx]['is_last'] = true;
}
/** end x-Links **/

// Now we put the buttons in the context so the theme can use them.
$menu_buttons = array();
foreach ($buttons as $act => $button)
if (!empty($button['show']))
{
$button['active_button'] = false;

// Make sure the last button truely is the last button.
if (!empty($button['is_last']))
{
if (isset($last_button))
unset($menu_buttons[$last_button]['is_last']);
$last_button = $act;
}

// Go through the sub buttons if there are any.
// BEGIN MOD MenuWithoutLimitLevel
$button = setupMenuContext_sub_buttons($button);
// END MOD MenuWithoutLimitLevel

$menu_buttons[$act] = $button;
}

mashby

Is it as easy as changing these two lines (near the end)?
FROM:
$buttons['logout']['is_last'] = false;
$buttons[$last_button_idx]['is_last'] = true;

TO:
$buttons['logout']['is_last'] = true;
$buttons[$last_button_idx]['is_last'] = false;

I'm not familiar with the mod, so if I'm wrong, you're best to look/ask in the support topic for that mod. I tried a simple search on x-Links and didn't find anything though.
Always be a little kinder than necessary.
- James M. Barrie

Matthew K.

You could use Menu Editor Lite as opposed to a menu mod that doesn't allow control over the order.

Realinfo

mashby............. it's still there............. no change............

Matthew K.

mashby's changes were correct, but they only changed the "is_last" as far as the variable is concerned, not the actual placement of the array.

mashby

So, now I'm curious...what is the x-Links mod? :)
Always be a little kinder than necessary.
- James M. Barrie

Antechinus

I have played with this sort of thing before a while back. Basically what you have to do is change the code in Subs so that the mod adds its buttons before the logout button. IOW, you have to break the array up and rearrange it. From memory it isn't all that difficult, but it's been a while and I can't remember the details offhand.

Matthew K.

Technically, you could just use array_slice(); although since you just need it before the last button, array_pop(); and then merging the three arrays might be the way to go. (or even array_push(); after array_pop(); is done).

Realinfo

I still not understand............. how I can make Logout as last button.................. X Links are of Menu Button MOD.......... by which we can add new button..............

Matthew K.

You should just use Menu Editor Lite which allows you to order the buttons.

Realinfo

Menu Order solve my issue................. thanks...........

Advertisement: