?
Solved

Help created a dynamic php menu via includes.

Posted on 2007-07-25
7
Medium Priority
?
364 Views
Last Modified: 2013-12-12
I have created a php real estate application, and i have the menu done in blocks with each block a seperate page and placed in the menu via includes.  What i'd like to be able to do is have a page in the admin section that would allow the user to turn off/on blocks using a form.  Is there any way to dynamically create a list of the available modules by the script getting the list from the includes/modules folder and then displaying the available ones in the admin section and also to display the active ones on the menu.
Also if possible there are some modules that should be displayed on the menu and other on the main page is there any way to seperate them and have the admin section decide where to place them.
Using php and mysql
Thanks in advance for any help.
0
Comment
Question by:Karen Liddy
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:rschoenbach
ID: 19564836
Yes, all this is a possible.

If I were to do something like this I would create a table in the database with all the modules and the location to some folder.

Table layout would look like this
module_id - int auto increment
module_name - varchar(??)
module_location - varchar(??)
menubar_location - varchar(??) or int(1) if you just have 2 sections they could go example - admin, menu

Then I would create another table with user id and what modules they want.
module_id int,
user_id int,
primary key(module_id,user_id)

In order to figure out where things do you reference the database and create dynamicly from it.

In the admin section let users add and delete modules on the fly.

I dont know what other people would recommend but this is how I would do it.
0
 

Author Comment

by:Karen Liddy
ID: 19592361
thank you for that, i did actually start to do it similarly but how do i get the script to show the pages, i have tried to put the path with the include statement and without, obviously that didn't work.  it's just that i've never tried anything like this i usually just work with getting data from mysql and listing it.

also how can i place them on different parts of the page depending on what they choose in the admin. for example, the mods payments, registration and news are active, one customer might want the news on the menu bar where another might want it on the main page, obviously i would have placemarkers so that the mods only appear in a certain place on the main page, but how do i make them move from the choice in the admin.

thanks for your help
0
 
LVL 4

Expert Comment

by:rschoenbach
ID: 19595954
all you have to do to get this to work is to pull the information from the database based on there user_id

second, create a numbering system where you have spots 1 - 10 that people can chose dynamically. when they choose where to put something add a record to the database.
0
 

Author Comment

by:Karen Liddy
ID: 19623571
thanks again for your answer.  i get how to do the database bit but what i don't know how to do now is: each modules first page is a .php file, and the file structure is :  /includes/modules/news/news_box.php, in the database how can i put in an include command or how do i get the menu to show the correct php file

I hope that i'm explaining myself properly.

thanks
0
 
LVL 4

Accepted Solution

by:
rschoenbach earned 1000 total points
ID: 19625487
just pull the modules that a user wants to use from the database and then use php to pull it in with an include statement.

while($row = mysql_fetch_array($module)) {
include('$.row['module']');
}
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to count occurrences of each item in an array.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Suggested Courses
Course of the Month17 days, 9 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question