SimplePortal

Development => Feature Requests => Topic started by: rocknroller on November 25, 2011, 03:19:28 PM

Title: Remove forum buttons from home page
Post by: rocknroller on November 25, 2011, 03:19:28 PM
Option to remove Main menu buttons from portal home page.

example:
- You can make custom pages, related to your activities and link them. Make custom menu eg. Contacts, About us, Forum.. etc.
Sometimes you do not want to have a forum in the foreground.

have that option it would be nice.  :)
Title: Re: Remove forum buttons from home page
Post by: Eliana Tamerin on November 25, 2011, 07:15:46 PM
You can do it by editing your Subs.php. For example:

Code: [Select]
'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(
),
),
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => true,
'sub_buttons' => array(
),
),
.
.
.
and so on

You can modify the 'show' lines, like so:
Code: [Select]
'show' => true,to
Code: [Select]
'show' => false,or
Code: [Select]
'show' => $current_action == 'forum',
I'm pretty sure the alternative would work as well, allowing you to keep all the links when you're on the forum, but not show them elsewhere.

So you could also modify the forum button's 'show' clause from:
Code: [Select]
'show' => in_array($modSettings['sp_portal_mode'], array(1, 3)) && empty($context['disable_sp']),to
Code: [Select]
'show' => in_array($modSettings['sp_portal_mode'], array(1, 3)) && empty($context['disable_sp']) && $current_action = 'forum',
Title: Re: Remove forum buttons from home page
Post by: rocknroller on November 26, 2011, 09:07:27 AM
thank you Eliana  :)

That is cool! but won't work for me.

 :| I tried like this also:

Code: [Select]
'show' => ($current_action == 'forum') ? 'true': 'false',
and I added in the global $current_action I do not know whether it is necessary, but won't work.
Title: Re: Remove forum buttons from home page
Post by: Eliana Tamerin on November 26, 2011, 09:18:58 AM
My bad on the last bit of code, it should be this:
Code: [Select]
'show' => in_array($modSettings['sp_portal_mode'], array(1, 3)) && empty($context['disable_sp']) && $current_action == 'forum',
And yours should be this:
Code: [Select]
'show' => ($current_action == 'forum') ? true: false,But this code is superfluous. The $current_action == 'forum' statement will evaluate to true if true and false if false.
Title: Re: Remove forum buttons from home page
Post by: rocknroller on November 27, 2011, 06:09:46 AM
Maybe I was not clear enough  :P

I want a forum button on (home page and SP pages), and only forum button.
I don't want other buttons(related to forum) to show on (home page and SP pages).
eg. Help, Profile, My messages, Members... etc.
 ;D
This code work for me:

Code: [Select]
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => ($context['current_action']) == 'forum',
'sub_buttons' => array(
),
),

but there is issue with other actions eg. action=help also make disappear help button. Can we make some kind of variable for which would know that user is on home page and portal pages.

Then use it example:

Code: [Select]
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => !$home_page OR !$sp_pages,
'sub_buttons' => array(
),
),
Title: Re: Remove forum buttons from home page
Post by: Eliana Tamerin on November 27, 2011, 05:24:18 PM
Ahh, now I understand what you want.

You will likely need to add in every action of the forum into the area of Subs.php with the $current_action definitions, like this:
Code: [Select]
if (isset($context['menu_buttons'][$context['current_action']]))
$current_action = $context['current_action'];
elseif ($context['current_action'] == 'search2')
$current_action = 'search';
elseif ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
elseif ($context['current_action'] == 'register2')
$current_action = 'register';
elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder'))
$current_action = 'login';
elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
$current_action = 'moderate';

You can find a complete list of SMF actions in the index.php file in your forum's root folder.
Title: Re: Remove forum buttons from home page
Post by: rocknroller on November 29, 2011, 12:04:28 PM
must be easier and aesthetic way :P

can I create php block and put it on pages I want and home page, then create variable eg.

Code: [Select]
$prem_buttons = 0;
and then somehow call it there  ;D
eg.

Code: [Select]
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => $prem_buttons = 0,
'sub_buttons' => array(
),
),
:)
Title: Re: Remove forum buttons from home page
Post by: [SiNaN] on November 29, 2011, 12:33:58 PM
Try this:

Sources/Subs.php

Code: (Find) [Select]
$context['menu_buttons'] = $menu_buttons;
Code: (Replace) [Select]
if (getShowInfo(0, '', '$php return ({$page} !== \'\' || \'{$portal}\' === \'1\');'))
foreach ($menu_buttons as $id => $button)
{
if (!in_array($id, array('home', 'forum', 'login', 'register', 'logout')))
unset($menu_buttons[$id]);
}

$context['menu_buttons'] = $menu_buttons;
Title: Re: Remove forum buttons from home page
Post by: rocknroller on November 30, 2011, 06:14:33 PM
yes, that works. :)  Thank you.

 Now it is look like a real portal  :P I guess it can add custom buttons and array it there to appear only on portal and pages. that is great! You should consider adding this option in the official version.
Title: Re: Remove forum buttons from home page
Post by: Marjorie on December 01, 2011, 01:22:16 AM
I don't support what you say.
Title: Re: Remove forum buttons from home page
Post by: Eliana Tamerin on December 01, 2011, 01:25:59 AM
Marjorie, do you have a similar issue like what's been presented here? Or another problem?
Title: Re: Remove forum buttons from home page
Post by: rocknroller on December 10, 2011, 07:28:15 AM
Try this:

Sources/Subs.php

Code: (Find) [Select]
$context['menu_buttons'] = $menu_buttons;
Code: (Replace) [Select]
if (getShowInfo(0, '', '$php return ({$page} !== \'\' || \'{$portal}\' === \'1\');'))
foreach ($menu_buttons as $id => $button)
{
if (!in_array($id, array('home', 'forum', 'login', 'register', 'logout')))
unset($menu_buttons[$id]);
}

$context['menu_buttons'] = $menu_buttons;

that is great but i found one fault, if you add button, appears on the forum too. that should only be on the home and pages.  :|
Title: Re: Remove forum buttons from home page
Post by: NightWalker on April 06, 2014, 07:55:32 AM
I have the same problem as the OP... sorry to reopen a old topic, but I got the same question so I guess its better to use this one... if I need to create another topic please let me know

the code that [SiNaN] give is awsome but is it possible to have a smiliar code for the forum?

I tried to add 'show' => !isset($_GET['action']) || $_GET['action'] != 'forum', on the bottuns that I dont want to show on the forum page, and it works, but only on the forum front page, if I got to a board, topic, PM, etc... all the other bottons appear....

I want the portal with is bottons and the forum and all forum directorys with differente bottons... is it possible?
Title: Re: Remove forum buttons from home page
Post by: pavshinAN on June 23, 2014, 08:02:52 AM
You can make custom pages, related to your activities and link them. Make custom menu eg. Contacts, About us, Forum.. etc (http://simpleportal.net/Smileys/SimplePortal/nervous-happy.gif) (http://1c.teobit.ru)
SimplePortal 2.3.8 © 2008-2024, SimplePortal