Jump to content

Recommended Posts

Hi guys

 

Just thought I would ask a question regarding modular design in PHP, as i,m having a bit of a hard time trying to get my head around it.

 

Ok, so I want to design a CMS with a modular approach with everything to run off of the index.php page, as its easier to implement SEF URL,s, for instance, say I want a news section, then I create a news module etc, etc.

 

What I also want to do, is dynamically build a site navigation menu, based on the modules installed, and this is what i,m not sure about, obviously, some modules I dont want to display in the menu for everyone, as I,m not going to want everyone to have an admin link for obvious reasons, now if it wasnt for this access restriction I could simply list use scandir() to see what modules were in the folder, but now I have to put this in a database.

 

Hopefully, extra modules are going to be installed through a CMS interface and file transfer system, so I want the module to install from a script included in the files that are uploaded.

 

I,m just at the initial roughing out of ideas stage for this project, and would be interested in your opinions and suggestions.

 

Thanks guys.

Link to comment
https://forums.phpfreaks.com/topic/142326-modular-system-design-questions/
Share on other sites

What I used to approach this was the following:

In the accounts/users table, create a field for securitygroup. Or more specifically in your case I would put in a field for an array of modules (like comma separated numeric values) that the user has subscribed to, purchased, or has access to.

 

then in your menu table you have each module that contains a numeric identifier (or some other type of GUID of your choosing)

 

That way when building your menu output, you would just parse out the array for that user's account (probably storing in a session variable or cookie) and your menu query would be like select * from menu where module_id in($parse1,$parse2,etc);

 

Then again in your menu table, you could have the landing page for each module to help build the menu and the index.php would handle it via the post/get variables from the form...

 

Using your "news" module as an example

 

the menu would say news, it would link to index.php?mod=2

 

the index.php page would either contain the array locally of modules like so:

$modules = array(

1 => 'index.php'

2 => 'news.php'

);

 

or you could query the database again

and it would just do an include('news.php'); statement in the appropriate output area to display the data.

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.