News:

Wondering if this will always be free?  See why free is better.

Main Menu

How to make a customed menu button active?

Started by Neverhurry, April 15, 2011, 11:06:34 AM

Previous topic - Next topic

Neverhurry

Hi, I need you help to make a customed menu button active. I tried some 4 hours but I failed. I even followed this (http://www.simplemachines.org/community/index.php?topic=410802.0) one but I had no luck. So I ask for your help. This is what I want to do: I want to add a customed menu botton "blog" which i did successfully in Subs.php, board 2 is for "blog" use.

'blog' => array(
'title' => $txt['blog'],
'href' => $scripturl . '?board=2.0',
'show' => true,
'sub_buttons' => array(
),
),


the problem is whenever i click the blog button, it doesn't turn orange, i.e. it doesn't get active, so that is my question, how to make this "blog" button active when it is clicked. Many many thanks.

I am using SMF 2.0.1, curve themes.

All Colours Sam

On your Subs.php file  find this:

elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
$current_action = 'moderate';



and below add this:

    elseif ($_REQUEST['board'] == '2')
$current_action = 'blog';

Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Neverhurry

Quote from: Miss All Sunday on April 15, 2011, 12:49:36 PM
On your Subs.php file  find this:

elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
$current_action = 'moderate';



and below add this:

    elseif ($_REQUEST['board'] == '2')
$current_action = 'blog';


Thanks, but no luck, when i click the blog button the active button goes to "Forums" button (I installed the PortaMX portal).  :'(
I am using SMF 2.0.1, curve themes.

MLM

Might want to have a peek at: http://www.simplemachines.org/community/index.php?topic=414518

This is a variation on Miss All Sunday's edit:


elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
$current_action = 'moderate';



and below add this:


elseif ($_GET['board'] == '2.0')
$current_action = 'blog';



ALSO TRY if that doesnt work:

elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
$current_action = 'moderate';



and below add this:


elseif ($_REQUEST['board'] == '2.0')
$current_action = 'blog';

My Themes:

My Mods:

Unsolved Threads:
  • None atm...

Neverhurry

MLM, i chedked that topic, i am happy it worked out for your case, but not mine. I don't have a homepage as you, so I tried to add $_GET['action'] = 'blog'; inside Subs.php (I don't know where else should I put), but it didn't work. It shouldn't be very far from success. I hope you or someone can give me a hand. Thanks a lot.
I am using SMF 2.0.1, curve themes.

Kays

Hi, you're in a bit of a funky situation since your blog is board. Something to try, (not tested)

In Subs.php look for:


$context['in_maintenance'] = !empty($maintenance);
$context['current_time'] = timeformat(time(), false);
$context['current_action'] = isset($_GET['action']) ? $_GET['action'] : '';


and add before it:


if (isset($_REQUEST['board']) && $_REQUEST['board'] == '2.0')
$_GET['action'] = 'blog';

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Neverhurry

Kays, thanks a lot, but no luck.  :'( When I click the blog button the active button goes to Forums (I installed the PortaMX portal, i think Portamx added that button, but I don't think that matters).
I am using SMF 2.0.1, curve themes.

Kays

#7
Try clearing your file cache. It does work for me when I checked it.

Edit: Just noticed that it won't highlight if viewing a post. ::)

Remove the previous code and after:


$context['current_action'] = isset($_GET['action']) ? $_GET['action'] : '';
$context['show_quick_login'] = !empty($modSettings['enableVBStyleLogin']) && $user_info['is_guest'];


Add:


global $board;
if ((isset($board) && $board == 2) || (isset($_REQUEST['board']) && $_REQUEST['board'] == 2))
$context['current_action'] = 'blog';

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Neverhurry

Quote from: Kays on April 17, 2011, 12:00:15 PM
Try clearing your file cache. It does work for me when I checked it.

Edit: Just noticed that it won't highlight if viewing a post. ::)

Remove the previous code and after:


$context['current_action'] = isset($_GET['action']) ? $_GET['action'] : '';
$context['show_quick_login'] = !empty($modSettings['enableVBStyleLogin']) && $user_info['is_guest'];


Add:


global $board;
if ((isset($board) && $board == 2) || (isset($_REQUEST['board']) && $_REQUEST['board'] == 2))
$context['current_action'] = 'blog';



Kays, I appreciate your help so much. I think you gave us a very good solution. But I can not have it work, because I have installed PortaMX. PortaMX added a forums botton when one activated a frontpage (that is my case, I activated a frontpage within Portamx). I don't know where are codes of PortaMX that are associated with SMF menu system, so I don't know how to deal with it, it looks too complicated to me so far. But I will ask in PortaMX side, they are very friendly and helpful, so if I have any news I will come back to update this topic.
I am using SMF 2.0.1, curve themes.

Neverhurry

Kays, I tried your codes:
global $board;
if ((isset($board) && $board == 2) || (isset($_REQUEST['board']) && $_REQUEST['board'] == 2))
$context['current_action'] = 'blog';


but it has no effect, very strange, is it because I have Portamx installed?

Because I have only one board (board 1) used as forum in my site, all other boards are for blog use, so I modified your codes to:

global $board;
if ((isset($board) && $board !== 1 ) || (isset($_REQUEST['board']) && $_REQUEST['board'] !== 1))
$context['current_action'] = 'blog';


The result is: when I click "forum" button it gets active, and when I click "blog" button (that opens the board 2) and it does get active. Looks like it works! Ach! But then when I click every other menu button (like "help", "profile","admin","member","calendar" etc.) the active all goes to "blog" button.

Can you still help? This active button problem is driving me crazy. Thanks ya!
I am using SMF 2.0.1, curve themes.

Kays

I thought that just one board was the Blog. You've got the url for the blog pointing at board 2.

Just installed PortaMx on a test forum and it is the culprit. But I can't see why in a quick look at the code. Any response from them as to how to highlight a tab?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Neverhurry

Quote from: Kays on April 21, 2011, 09:04:01 AM
I thought that just one board was the Blog. You've got the url for the blog pointing at board 2.

Board 2 is the board that contains more child boards that are used as "blog"....  ;).
So if one click the "blog" board 2 is opened, but one see child boards (blogs) listed here. There is only one post inside Board 2 to explain to users how to apply blog. Board 2 is a reply only board.

Quote
Just installed PortaMx on a test forum and it is the culprit. But I can't see why in a quick look at the code. Any response from them as to how to highlight a tab?

It seems that Feline has something fresh and great, I just found it but I haven't tested it yet (too late in the night, tomorrow i will do).

this is the link:

http://portamx.com/2419/how-to-make-custommed-menu-button-active/msg14047/topicseen/#new
I am using SMF 2.0.1, curve themes.

Kays

Any luck with that suggestion.

If your other boards are children of the main board then each will need to be added to that check. But that's something which can be looked at after you get it working with one board.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Neverhurry

Quote from: Kays on April 23, 2011, 12:19:36 PM
Any luck with that suggestion.

If your other boards are children of the main board then each will need to be added to that check. But that's something which can be looked at after you get it working with one board.

Hi Kays,

really sorry being busy with so many easter activities that I can sit to test it only today.... : ;) :D

And, it works like a charm, when you click the blog button it get active and when you enter the blog topics it shows the active blog button all the time. So it is great! Fel was right, a simple trick that fix it.

But, but, there is a small problem, as you predicted, the children boards don't work, that means if I go to the children boards of the blog (board) then the active button become "Forum".

I really wish that you can help, it is almost almost done!!!

Thank you for stucking on this topic and encouraging me to solve this problem.  :D
I am using SMF 2.0.1, curve themes.

Kays

Great, The rest might be easier that I originally thought. :)

Rather than checking $board. Stick all of the non-blog topics into one category and check $board_info['cat']['id'] instead. Otherwise you'll need to use if(in_array)) and add the board ids manually.

Something like:


global $board_info;
if (!empty($board_info) && $board_info['cat']['id'] == 1)
{

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Neverhurry

Kays, thanks a lot for this inspiration.
I have just one category in that SMF forum, so I didn't test yet. Have to create another SMF forum to test it. But I think your codes should work.

I have 2 questions.
First, do you think i can add your codes after the following code in index.template.php if I put all the blog boards into category 2?

foreach ($context['menu_buttons'] as $act => $button)
{


Second, when I looked at Fel's codes,

   if(!empty($context['current_board']) && $context['current_board'] == '2')
{
if($act == 'blog')
$button['active_button'] = true;
else
$button['active_button'] = false;
}



I thought, actually all my blog boards are board 2's child boards, so, logical they share one parant board, i.e., id_parent == 2, so I changed a little bit of Fel's codes to:

   
                global $board_info;
                if(!empty($context['current_board']) && $context['current_board'] == '2'
                    || if (!empty($board_info) && $board_info['id_parent '] == 2)
{
if($act == 'blog')
$button['active_button'] = true;
else
$button['active_button'] = false;
}


I am not good at php, so can you have a look at the codes above, please?
I am using SMF 2.0.1, curve themes.

feline

if you have child boards, add they id here like:

if(!empty($context['current_board']) && in_array($context['current_board'], array(2,3,4,5)))

Neverhurry

Quote from: feline on April 27, 2011, 12:33:28 PM
if you have child boards, add they id here like:

if(!empty($context['current_board']) && in_array($context['current_board'], array(2,3,4,5)))


WOW, Feline, you are marvelous! Kays, your way is wonderful too. Praise be to both of you!!! Thanks a million.  ;)
I am using SMF 2.0.1, curve themes.

Kays

Maybe I should of explained a bit better. Since all of the boards are in the same category, it's not necessary to check for the board id. Also If you do add additional boards, you won't need to add then to the arrays.

This seems to work if category 2 is the category where the bogs are in.


foreach ($context['menu_buttons'] as $act => $button)
{
global $board_info;
if (!empty($board_info) && $board_info['cat']['id'] == 2)
{
if($act == 'blog')
$button['active_button'] = true;
else
$button['active_button'] = false;
}

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Neverhurry

Kays, that's fantastic. Beautifully done. I close this topic now. Thanks a lot for your help.
I am using SMF 2.0.1, curve themes.

Advertisement: