RecoilUK Posted January 25, 2009 Share Posted January 25, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/142326-modular-system-design-questions/ Share on other sites More sharing options...
kodosai Posted January 27, 2009 Share Posted January 27, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/142326-modular-system-design-questions/#findComment-747956 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.