Page 1 of 1

CMS: Multiple modules causes duplicate Class/Functions

Posted: Mon May 22, 2006 10:11 am
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.

Posted: Mon May 22, 2006 10:18 am
by feyd
Use include_once() and instantiate a new instance for each location they are requesting?

Posted: Mon May 22, 2006 10:29 am
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