Jump to content

Changing menus for a CMS


Killswitch

Recommended Posts

Hello all,

I am working on a small CMS application.  I have thus far avoided using any realy templating architecture (Smarty, PatTemplate, etc) and stuck with just including three files.

 

It uses MySQL database and so far is coded to work with php 4 and 5 (have yet to use any classes, will get into it later).  I am stuck at the moment on something that probably has a relatively simple solution, but I am new to developing any large scale application such as a CMS.

 

I can add, edit, delete content, place them in categories and sections (similar to Drupals page and node I guess), etc at this point in time.  Now for the problem... I want to be able and have new menus appear or disappear depending on which section I am in and really dont know the best way to go about doing this (I dont want to overkill the application and dont want to overcode something if there is a simple way to do this). 

 

For example, if I have a products link in my main menu, which appears on every page of the site, when you follow it, I want a new menu to appear that contains links to different products or content.  The url would be something like index.php?id=2&sid=5&cid=7... etc etc etc.

 

Any ideas on the simplest way to go about doing this?  I will later be setting it so that I can choose from the backend whether I want each menu to the right or left side of my site, but dont really know how I want to go about doing this.

 

Thanks for any help freaks ;) Happy coding.

Link to comment
Share on other sites

My CMS architecture stores menus in a table. Each menu has a menuID and a related pageID. When displaying a page from the site, I lookup which page it is displaying (by the url matching it the the pageID) which then gives me which menu to show.

 

In my menus table is a parent > child relationship. Some menus are children of the parent menu. This defines the menu heirachy. I use a recursive function to create the menus, looping through parent and child etc till all elements have been outputted.

 

Design your database efficiently first, and your application will design itself :)

Link to comment
Share on other sites

Design your database efficiently first, and your application will design itself :)

 

Thanks, great advice.  I as well want my menus in the database, and figured I would end up looping them through an array, but wasnt really sure if it would be too efficient.  I know my menus will relate to the section rather than the pages, so I figured I would link them to that. 

 

I only have a bit over a years worth of coding experience, never really dealt with this before (have used associative arrays for something similar before), so I am kinda just jumping into any logical way I can see.  Thanks for sharing, will continue to build and see what happens.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.