View Full Version : Dynamic Navigation menu - all your Custom CMPS Pages
Natch
08-03-2004, 10:16 AM
What this does: creates a Navigation menu (best as a left or right side block) which is populates automagically by the custom pages you have inserted into your CMPS. It should only show the user the pages that they have permissions to view.
Step 1: create and upload a new module modules/navmenu.php with the contents<?
// edit this var if you wish a custom name for your homepage link
$homepage_name = $vboptions[hometitle];
// end var editing
$nav_menus = $DB_site->query("SELECT pageid,name,title,userperms FROM " . TABLE_PREFIX . "adv_pages");
while($nav_menu = $DB_site->fetch_array($nav_menus))
{
$title = ($nav_menu['pageid']==1) ? $homepage_name : $nav_menu['title'];
$groupperms = explode(",",$nav_menu['userperms']);
$membrperms = fetch_membergroupids_array($bbuserinfo);
foreach($membrperms as $usergroup)
{
if(in_array($usergroup,$groupperms) && ($pagename != $nav_menu['name']))
{
$bgclass = exec_switch_bg(1);
$pagename = $nav_menu['name'];
eval('$pages_menubits .= "' . fetch_template('adv_portal_pagesmenubits') . '";');
}
}
}
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_pagesmenu') . '";');
?>Step 2: Create a new template adv_portal_pagesmenu with the contents:<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<thead>
<tr>
<td class="tcat">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('cmps_pagesmenu')"><img id="collapseimg_cmps_pagesmenu" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_cmps_pagesmenu].gif" alt="" border="0" /></a>
<span class="smallfont"><strong>$vba_options[portal_blockbullet] Navigation</strong></span>
</td>
</tr>
</thead>
<tbody id="collapseobj_cmps_pagesmenu" style="$vbcollapse[collapseobj_cmps_pagesmenu];text-align:$stylevar[left]">
$pages_menubits
</tbody>
</table>
<br />Step 3: Create a new template adv_portal_pagesmenubits with the contents:<tr>
<td class="$bgclass" style="text-align:right">
<span class="smallfont">
<!-- edit this entry to alter the index.php if your cmps portal has a different filename -->
<a href="$vboptions[homeurl]/index.php?$session[sessionurl]<if condition="$pagename!=home">$vba_options[portal_pagevar]=$pagename</if>" title="link to $title page">$title</a>
</span>
</td>
</tr>Step 4: Create a new CMPS module, with the following settings (other than the defaults):
Module Title: Page Navigation
File To Include: navmenu.php
Templates used: adv_portal_pagesmenu, adv_portal_pagesmenubits
HTH y'all :) I like it ;)
Demo (http://www.mobileforces.org/) <= this shows only one link available due to Guest permissions
Login with test/testicular to see the menu populate with extra pages
EDIT:// Altered the module; if you have installed this prior to now, please update the contents of your module with the edited one above.
KW802
08-03-2004, 10:26 AM
Natch, is there a link somewhere on the demo site to a custom page to see the menus change in action? :D
Natch
08-03-2004, 10:43 AM
What do you mean "menus change in action" ... you mean to show them altering based on permissions ?
KW802
08-03-2004, 10:51 AM
What do you mean "menus change in action" ... you mean to show them altering based on permissions ?
Maybe I'm misunderstanding what it does. :confused: From the description I was it interpreting to mean that if I create a new page in CMPS then the menu will dynamically change along with it. From the demo site, though, I couldn't find any links to a custom CMPS page.
(I think I'll go get some caffiene & come back to read this thread again to see if I'm missing something.... :D )
Natch
08-03-2004, 11:05 AM
OK - you as a non user will only see one link ... if you login with test/testicular you will see the menu change ...
Sorry - I forgot about the user access - but this makes it a good demo ;)
Updated instructions
KW802
08-03-2004, 11:22 AM
OK - you as a non user will only see one link ... if you login with test/testicular you will see the menu change ...
Sorry - I forgot about the user access - but this makes it a good demo ;)
Updated instructions
I see you changed the password. ;) The pre-edit password wasn't working so I created a KW802 account.
Looks pretty good in action. :cool:
Natch
08-03-2004, 11:33 AM
Cheers - I'm just working out one bug where if your members have multiple usergroups the menu items appear more than once ...
I'll get it sorted soon...
Natch
08-03-2004, 11:36 AM
OK: if you have this installed already, find in the module navmenu.php: if(in_array($usergroup,$groupperms))
Replace with:if(in_array($usergroup,$groupperms) && ($pagename != $nav_menu['name']))I'm updating the instructions now.
-peace-
10-04-2004, 02:19 PM
Ok this works, BUT, since I am using this for a group - lets call the group accounting, - and I want the acct group to have there own menu which no one can see besides the acct group - this is fine.
I want to build another for a group called - sales - and they are a group and there pagesmenubits are different than the acct group. I renamed the pagesmenubits to pagesmenubitssales and the pagesmenu to pagesmenusales and the navmenu to navmenusales. This doesnt work
here is my code - what am I missing here?
navmenusales.php
<?
// edit this var if you wish a custom name for your homepage link
$homepage_name = $vboptions[hometitle];
// end var editing
$nav_menus = $DB_site->query("SELECT pageid,name,title,userperms FROM " . TABLE_PREFIX . "adv_pages");
while($nav_menu = $DB_site->fetch_array($nav_menus))
{
$title = ($nav_menu['pageid']==1) ? $homepage_name : $nav_menu['title'];
$groupperms = explode(",",$nav_menu['userperms']);
$membrperms = fetch_membergroupids_array($bbuserinfo);
foreach($membrperms as $usergroup)
{
if(in_array($usergroup,$groupperms) && ($pagename != $nav_menu['name']))
{
$bgclass = exec_switch_bg(1);
$pagename = $nav_menu['name'];
eval('$pages_menubitssales .= "' . fetch_template('adv_portal_pagesmenubitssales') . '";');
}
}
}
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_pagesmenusales') . '";');
?>
adv_portal_pagesmenusales
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<thead>
<tr>
<td class="tcat">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('cmps_pagesmenu')"><img id="collapseimg_cmps_pagesmenu" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_cmps_pagesmenu].gif" alt="" border="0" /></a>
<span class="smallfont"><strong>$vba_options[portal_blockbullet] Navigation</strong></span>
</td>
</tr>
</thead>
<tbody id="collapseobj_cmps_pagesmenu" style="$vbcollapse[collapseobj_cmps_pagesmenu];text-align:$stylevar[left]">
$pages_menubitssales
</tbody>
</table>
<br />
adv_portal_pagesmenubitssales
<tr>
<td class="$bgclass" style="text-align:right">
<span class="smallfont">
<!-- edit this entry to alter the index.php if your cmps portal has a different filename -->
<a href="$vboptions[homeurl]/index.php?$session[sessionurl]<if condition="$pagename!=home">$vba_options[portal_pagevar]=$pagename</if>" title="link to $title page">$title</a>
</span>
</td>
</tr>
Step 4: Create a new CMPS module, with the following settings (other than the defaults):
Module Title: Page Navigation2
File To Include: navmenusales.php
Templates used: adv_portal_pagesmenusales, adv_portal_pagesmenubitssales
wildthinks
10-16-2004, 03:04 PM
HI,
http://Swishzone.de/index2.php
I have a problem with the navigation. I created a page called "datenschutz" -> http://swishzone.de/index2.php?page=datenschutz
this work, but dont show on the navigation box...
I followed the instruction.
My Language is english.
Thank you
WT
Punktek
10-27-2004, 10:46 PM
Mine doesn't work...Its weird...it just doesn't show up. I followed al lthe steps. Doesn't show up on parent style or any of childerned styles.
Anythign I should check?
EDIT:: I jsut noticed whenever I save the settings for the module the navbar.php thing becoems desleceted...Its only letting me use a template or php file for some reason.
DSMrSinister
10-29-2004, 12:50 AM
kewl mod.. great work natch..
:)
I will install Later!
IFor[You]
12-11-2004, 11:04 PM
aw...
doesn't work for me
i only get the category strip
Natch
12-12-2004, 05:26 PM
OK: is it possible you have missed out installing the second template?
IFor[You]
12-13-2004, 06:30 AM
nope
i followed the instructions...
bulbasnore
12-31-2004, 10:23 AM
OK, as far as having different groups have different menus, here is what I did:
1) I used a "page identifier" for all the pages for that group starting with a unique prefix (e.g. cpdm).
2) I made copies of the templates with text appropriate to the group.
3) For consistency, I used the prefix in the template names.
4) I made a copy of the module script, also with the same prefix.
5) In the script I changed the template names to match the templates from #2.
6) I changes the SQL statement as follows (commented out the existing on with leading //, copied it to next line, removed the comment mark and then...):
$nav_menus = $DB_site->query("SELECT pageid,name,title,userperms FROM " . TABLE_PREFIX . "adv_pages WHERE name like 'cpdm%'");
This means find the pages named starting with "cpdm". Watch out for the quote/double quote marks and definitely don't just change the line with out copying it and commenting it first unless you're an sql maven, or you'll have to re-upload the script.
Slave
01-29-2005, 06:12 AM
Hmm .. not sure why as it did work .. but it's now not picking up any new pages that I create ..
Is there a certain period of time you have to wait before it "sees" new pages?
(I'm using CMPS 1.0.1 btw .. would that be making a difference?)
Slave
01-29-2005, 06:32 AM
hmm .. I edited the new page and turned off all of the permissions and then turned them all on again and saved .. and the page now shows in the Nav box ..
Weird .. but working again :)
smolie
02-02-2005, 07:34 AM
cool, been searching for this menu, but is it also possible that this menu is showing up in the left column as a module????
Zejari
02-14-2005, 12:48 AM
any chance you're still supporting this?
Natch
02-15-2005, 12:17 AM
What's your question?
MikeR
02-22-2005, 04:16 AM
I have a question on this actually. I installed it and it works great for registered users however guests get a nasty php error until they register. My forum is wide open to guests so just wondering what I can do to fix this.
Thanks
Natch
02-23-2005, 08:10 PM
To know where it is, I'd need to see the error, or have the error message pasted in here?
venomx
02-25-2005, 04:16 AM
Seems something is wrong. What we are to put into the templates isnt showing.. :(
Natch
02-26-2005, 01:21 AM
Questions:
Are you sure that you are putting the templates into all your styles, or at least into a parent style of the one you are testing with?
If you have problems, I'd live to be able to see where they are showing up: if you can PM me with URL's including a temp admin access as well as your test basic user account so I can see how it behaves for different permissions, the templates and the CMPS config.
venomx
02-26-2005, 02:41 AM
Was talking about here. But seems like they are back :)
Punktek
03-06-2005, 07:04 PM
Won't work for me. I get no php errors but..well let me explain.
My server is set up to when there is a php error it jsut shows a blank page but I casn view it with errors through my server cp. When I do this there aer no errors shown on the page and the nav bar is there. Its liek it is treating the navbar as errneous coding. Any suggestions?
Hi, this looks neat. :) Is it working on 3.0.7?
Punktek
03-13-2005, 03:56 PM
I have found my problem but need help fixing it. www.supportcore.org
Whever I activate it the html tag there at the very bottom won't close. When I deactivate it the html tag is closed. What tempalte do I need to edit?
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.