CMS: Multiple modules causes duplicate Class/Functions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AlexC
Forum Commoner
Posts: 83
Joined: Mon May 22, 2006 10:03 am

CMS: Multiple modules causes duplicate Class/Functions

Post by AlexC »

Hey,

I'm currently working on a small, yet powerfull CMS system that is compltly modular. The way inwhich it will work is that the Admin can choose which modules go into what 'sector' of the template file. Then, the requested module ( Which comes from the URL, EG index.php?mod=news ) is then included into the main content area ( Specified by the template file ).

Each module is wraped in a class called mod{modname} ( EG modNews ), I thought this was a good way to do it at first - BUT if the admin has specified that he/she wants the News module in say the left sidebar area and then the requested module is also the news module ( index.php?mod=news ) this will cause duplicate Class/Functions and causes a fatal error.

How do other CMS's allow duplicate modules in this way? I've spent days trying to think how I can make these two ( or more ) identical modules unique but I can't.

Please can someone help me, if you don't understand please say and I will try to explain it better.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Use include_once() and instantiate a new instance for each location they are requesting?
AlexC
Forum Commoner
Posts: 83
Joined: Mon May 22, 2006 10:03 am

Post by AlexC »

Hum that would work, but i'm using a tag replacement system for my template files. The template file contains sectors like this: {S1} {S2} {S3} and then the requested module is loaded into {SC}

The admin 'plugs' a module into one of the {Sx} sectors. My tag replacement code then replaces the {Sx}'s with the correct module PHP File ( and parsed it at the same time, I belive ) based on an entry in the MySQL database.


EDIT: nono, I think i've got it! give me untill tomorrow and i'll see what I can come up with! yay 8O :P
Post Reply