Simple Machines Community Forum

Customizing SMF => Graphics and Templates => Topic started by: Realinfo on January 17, 2012, 09:58:15 PM

Title: Logout as a last button
Post by: Realinfo on January 17, 2012, 09:58:15 PM
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;
}
Title: Re: Logout as a last button
Post by: mashby on January 17, 2012, 10:09:38 PM
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.
Title: Re: Logout as a last button
Post by: Matthew K. on January 17, 2012, 10:09:48 PM
You could use Menu Editor Lite as opposed to a menu mod that doesn't allow control over the order.
Title: Re: Logout as a last button
Post by: Realinfo on January 17, 2012, 10:36:58 PM
mashby............. it's still there............. no change............
Title: Re: Logout as a last button
Post by: Matthew K. on January 17, 2012, 10:42:27 PM
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.
Title: Re: Logout as a last button
Post by: mashby on January 17, 2012, 10:44:33 PM
So, now I'm curious...what is the x-Links mod? :)
Title: Re: Logout as a last button
Post by: Antechinus on January 17, 2012, 10:46:34 PM
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.
Title: Re: Logout as a last button
Post by: Matthew K. on January 17, 2012, 10:48:34 PM
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).
Title: Re: Logout as a last button
Post by: Realinfo on January 18, 2012, 06:21:57 AM
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..............
Title: Re: Logout as a last button
Post by: Matthew K. on January 18, 2012, 11:07:44 AM
You should just use Menu Editor Lite which allows you to order the buttons.
Title: Re: Logout as a last button
Post by: Realinfo on January 18, 2012, 12:29:27 PM
Menu Order solve my issue................. thanks...........