Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:01
Menu concatentation
Poster: vharris6
Dated: Wednesday June 20 2012 - 20:33:10 BST
I have what is most likely a relatively common problem, but have no clue how to solve it, technically: based upon a person's role who has logged in concatenate menu snippets together.
Right now what I am doing is defining a multiple menu files and store their location in a table. Then, based upon the login and role lookup I choose I choose the appropriate menu file and insert it, via PHP, into the HTML stream.
Works fine.
But here's the rub: everything I specify a new role and/or new function I have this awful editting session: (1) update the master menu (has everything); update Finance Administer variant, Customer variant, etc., etc. As I said this "works" but it sure is time consuming and can be prone to error (of course).
So here is what I was thinking:
> establish separate menu files for various collections of items
> Based upon role, select the appropriate menu files and concatenate them into a single menu file using PHP commands. Then write the file as a session variable which is then simply referenced in the HTML script.
Is this viable? Doable? How have others solved this problem?
I suppose, alternatively, I could store everything in a database and write the MILONIC file specialized to the user when the login. I sure would like to avoid all this work, though.
Thoughts, suggestions, working examples very much welcome.
Victor Harrison.
PS: one more thing: I store locations for various script files in session variables. I noted the one post solved the problem of location by coding the location into the MILONIC script. OK, I can do that. But sure would be nice to reuse all those session variables instead of creating a new technique. I can't resolve the variable pre-processor mode given the nature of JS, so is there a alternative way to reuse already created session variable?
Re: Menu concatentation
Poster: Ruth
Dated: Wednesday June 20 2012 - 21:50:28 BST
Hi,
I have posted this to Milonic as it is beyond what I know and you should get a response soon. I have also found a couple of posts that talk about sessions variables and using them for specific things which might give you some info.
viewtopic.php?f=10&t=9097&hilit=session+variables
viewtopic.php?f=10&t=9897&p=46676
Sorry I couldn't be more help.
Ruth
Re: Menu concatentation
Poster: vharris6
Dated: Thursday June 21 2012 - 9:15:14 BST
Ruth,
Thanks for the posts! I look forward to further information from Milonic.
In the mean time, your first post - where they changed the menu file from a .js extension to a .php extension looks like this will be the basis for my solution. No clue why I did not think of doing that. Duhhh.
I can use my logon and bootstrap scripts to pre-process the menu file to my heart's content and then write the resultant file .js file as a session variable and just reference that in my web pages (already doing a PHP Session variable reference). As an extra goodie I can now use my standard session variables for file locations and security checking in the script, too!
Yahoo!
I think.
So, here's a restaurant question: any thoughts on how to manage the details using this technique in the first post?
Consider this example where a session variable holds the role of someone who has logged on:
Code:
<?php
if (($_SESSION['role_type']='SuperAdmin') || ($_SESSION['role_type']='Admin') || ($_SESSION['role_type']='whatever')) {
echo 'aI("text=Al\'s Menu;url=http://www.pollenz.net;")
';
}
?>
if (($_SESSION['role_type']='SuperAdmin') || ($_SESSION['role_type']='Admin') || ($_SESSION['role_type']='whatever')) {
echo 'aI("text=Al\'s Menu;url=http://www.pollenz.net;")
';
}
?>
The problem is this is it is pretty brittle. New roles would require manual updating to the code plus a detailed association of a screen to a role. I suppose I could build a DRUPAL-like role-to-function matrix and do checkboxes, store it in a table, and use that to drive the detailing of the menu file. Looking forward to how others may have addressed this problem.
PS: If I only had 10 or 20 work screens I might just bite the bullet and do it all inside the Milonic file, but I don't. Hence, I am worried about ongoing maintainability.
Victor
Re: Menu concatentation
Poster: Ruth
Dated: Thursday June 21 2012 - 20:26:48 BST
Hi Victor,
I'd be glad to help, but my knowledge of php is zilch. I can sort of figure out what you posted is saying, more or less [probably less] but that's about it. And, if you're going to add 'roles' I'd think you'd have to make that change anyway in your code or not, what do I know By my statement, I'm sure you can figure out "I no nothing", as Schulz would say!
Ruth
Re: Menu concatentation
Poster: vharris6
Dated: Thursday June 21 2012 - 21:16:32 BST
Thnkyou for taking time, Ruth.
I think at this point I am into a Drupal-like screen where I create a "spreadsheet" like form with the COLUMNS being roles and ROWS being screens (both are in a mySQL database). Then, with each cell I place a "checkbox" in it. If it is checked I pickup a snippet of your code format at create the menu.
Blehhhhh.
Done something like this before. Doable, but a fair amount of work. Would be a nice feature, though.
So, I guess, I am into doing adds/chgs/deletes of screens to the role based menus manually.
Double-Blehhhh.
Re: Menu concatentation
Poster: Ruth
Dated: Thursday June 21 2012 - 22:18:12 BST
Well, I would bet Andy will know what you are attempting and maybe yours is the only solution but he may have another, I don't really know. Usually Milonic responds pretty quickly. You could go to the main site: http://www.milonic.com/ and at the bottom there is a link for Tech Support. Note that you need a valid license and tech support level to use this, then fill out a ticket with your explanation. I will also post again to Milonic, I'm surprised they have not yet responded since they are usually very quick.
Ruth