News:

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

Main Menu

Menu tabs

Started by Acans, September 08, 2010, 01:49:11 AM

Previous topic - Next topic

Acans

Hi all.

I'm working on a easy tip and trick, however its not so easy for me :p

I'm trying to add tabs to the menu that require the feature to be enabled first, however I cannot seem to get it to work.

I've been trying this, but with no luck.


'reports' => array(
'enabled' => in_array('rg', $context['admin_features']),
'title' => $txt['generate_reports'],
'href' => $scripturl . '?action=admin;area=reports',
'show' => allowedTo('admin_forum'),
),
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

IchBin™

You would put your check in the 'show' => allowedTo('admin_forum'), section. You can put multiple checks in it.

'show' => allowedTo('admin_forum') && in_array('rg', $context['admin_features']),

As long as it returns true or false I think.
IchBin™        TinyPortal

Acans

I thought that was only permissions, because i've setup some tabs like that too.

I'll try it this afternoon.

I'm currently at school.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

Acans

Doesn't work.

What I'm trying to do is if reports isn't enabled in core features, than not show the tab.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

IchBin™

Well how are you checking to see if it's enabled? Need to see what code you're trying if you want help.
IchBin™        TinyPortal

Acans

in_array('rg', $context['admin_features']),

Thats the code in admin.php and i was hoping it would work in subs.php

If its going to be to much an issue don't worry. I made a lazy admin menu, well, cause I'm lazy, and i thought it might be nice to share it.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

IchBin™

Post your code. I have just tested this myself and it works just fine.

'mybutton' => array(
    'title' => 'Test',
    'href' => 'http://www.ichbin.us',
    'show' => in_array('ml', $context['admin_features']),
    'sub_buttons' => array(),
    'is_last' => true,
),


This is assuming that your 'rg' is actually in the $context['admin_features'] array. Have you checked that?

print_r($context['admin_features'])
IchBin™        TinyPortal

Acans

if you mean in the:

// Set up the menu privileges.

For $context['admin_feautres']) Than no, its not.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

IchBin™

What I'm saying, is that you are checking for in_array('rg', $context['admin_features'])

Does rg exist in the $context['admin_features'] array ? Have you checked? You can see by doing a print_r() like I showed you above. That is why I used 'ml' because I knew it was in the array.
IchBin™        TinyPortal

Advertisement: