Page 1 of 1

Switches in overall_header.tpl to Select Javascript Menu

PostPosted: Sun Apr 16, 2006 3:11 pm
Author: Dr. Bantham
I am using a javascript menu system which is totally independent of IntegraMOD menus, including Qbar. At first I created a singular generic menu which sufficed for all log states. Now, I have decided to create separate menus for visitors, members and administrators. I felt that the best way to handle this was with switches, as previously demonstrated by:

<BEGIN>
INSERT CODE HERE
<END>

This code handles the member state well, as it only executes the code if the visitor is logged in.

I found a small mod which allows for the same function relative to administrators:
[url=http]Admin View Only[/url]

My problem is how do I do the same for visitors not logged in? Right now, I have a sequential series of menu calls. The first calls a visitor menu (without a test), the second calls for a member menu (logged in test), and the third calls for the admin menu (admin test). This actually works, since the first menu is always called each subsequent successful menu call creates a javascript menu over the previous one. If you have a good broadband connection, the stacking of menus is hardly noticeable. My concern is that dial-up users may experience a considerable lag as the menus are called, especially since this menu cycle is a part of overall_header.tpl and is called with every page. I also noticed a horrendous lag when Opera encountered this section of code. Opera seems to behave with a singular menu.

You can have a look at the result here:
[url=http]THOMAS LIGOTTI ONLINE[/url]

I need a way to define a single menu selection for each state. A successive if, then...else statement would be ideal. I know very little PHP, however.

Basically, the logic would be

If ADMIN then AdminMenu
---> else if USER then UserMenu
-------->else VisitorMenu

Note that I am using generic variables for the logic. The above is not my feeble attempt at coding, though it may not be far from the mark! I may be totally off base on my approach here. I would greatly appreciate any help!

Re: Switches in overall_header.tpl to Select Javascript Menu

PostPosted: Wed Apr 19, 2006 3:57 pm
Author: Dr. Bantham
After poking around in page_header.php I discovered that a switch for users logged out was also available. This solved the greater half of my problem, as standard members will either get the visitor menu or the member menu, but not both. However, I have still not found a way to prevent both a member menu and an admin menu being loaded. I am listing the code below for comments. Thanks in advance!
Code: Select all
<BEGIN> <ALLWEBMENUS><END>  <BEGIN> <ALLWEBMENUS> <END>  <BEGIN>  <ALLWEBMENUS> <END>

Re: Switches in overall_header.tpl to Select Javascript Menu

PostPosted: Thu Apr 20, 2006 1:11 am
Author: found it
this mod will allow you to add switches for mods and admin view only

Code: Select all
############################################### ##   Hack Title]http://www.phpbbhacks.com/forums[/url] for support. ############################################### ## ############################################### ##   This hack is released under the GPL License. ##   This hack can be freely used, but not distributed, without permission. ##   Intellectual Property is retained by the hack author(s) listed above. ###############################################  # #-----[ OPEN ]------------------------------------------ #     includes/page_header.php# #-----[ FIND ]------------------------------------------ # //// Login box?//if ( !$userdata['session_logged_in'] ){     $template->assign_block_vars('switch_user_logged_out', array());}else{     $template->assign_block_vars('switch_user_logged_in', array());       if ( !empty($userdata['user_popup_pm']) )     {         $template->assign_block_vars('switch_enable_pm_popup', array());     }}# #-----[ AFTER - ADD ]------------------------------------------ # if ( $userdata['user_level'] == MOD ){     $template->assign_block_vars('moderators_only', array());}else if ( $userdata['user_level'] == ADMIN ){     $template->assign_block_vars('admins_only', array());}else if ( $userdata['user_level'] == MOD || $userdata['user_level'] == ADMIN ) {     $template->assign_block_vars('admins_and_moderators_only', array());}# #-----[ STOP ]------------------------------------------ # This is where you need to determine which switches you want to add.  Below is the code forADMINS ONLY, MODERATORS ONLY and for both MODS AND ADMINS.  Find the proper content that you want to hideand add the BEGIN switch just before and add the END switch just after your content.  -------  ADMIN ONLY SWITCHES --------  # #-----[ OPEN ]------------------------------------------ #     templates/subSilver/*# #-----[ BEFORE - ADD ]------------------------------------------ #     <BEGIN># #-----[ AFTER - ADD ]------------------------------------------ #     <END># #----------------------------------------------- #  -------  MODERATOR ONLY SWITCHES --------  # #-----[ OPEN ]------------------------------------------ #     templates/subSilver/*# #-----[ BEFORE - ADD ]------------------------------------------ #     <BEGIN># #-----[ AFTER - ADD ]------------------------------------------ #     <END># #----------------------------------------------- #  -------  MODERATOR & ADMINS ONLY SWITCHES --------  # #-----[ OPEN ]------------------------------------------ #     templates/subSilver/*# #-----[ BEFORE - ADD ]------------------------------------------ #     <BEGIN># #-----[ AFTER - ADD ]------------------------------------------ #     <END># #-----[ SAVE & CLOSE ALL FILES ]-------------------------- # #End  


I dont know if it helps at all....

:mrgreen:

EDIT email address in script modified - A