5
Quote:
However, several problems still remain... creating function and class names. Also, template files are currently named with the module-name in the filename. e.g. modules/news/templates/news_item.html. This is something you definitely could *not* generate dynamically, so cloning a module would require at minimum renaming the template files. (Possibly it will also require a search/replace in function names and class names.)
Really? Several things occur to me:
1. For code inside a module (ie. NOT blocks, which are a special case), each file will have #include statements to get access to all of the module's functions and classes. Because these include statements use relative paths (or, at least, they should for what we are trying to do), each clone of the module will look only at its own implementation. If all of the SQL statements are written in the dynamic fashion described above, then there is no problem, and you don't have to do any search and replace or dynamic function names or anything like that. Please correct me if I am wrong here.
(Even if classes are defined globally, a page within one module should not be loading class definitions for another module, right? (blocks aside, of course, which screws eveything up.))
Obviously, blocks are a more difficult problem, as was described above, but every block's code is still within THAT module's directory, so using the file path everywhere in the code should still work, right? I'm not sure what I am missing here.
2. Templates. I agree that because of the way they are stored in the database, they probably need unique names for each clone. Somewhere in the documentation for installing the templates, there needs to be instructions that each of the template files need to be renamed appropriately. Then, using $VarPrefix or $ModuleName or something like that when referencing the templates should be enough. I like this solution because the less a user has to tweak a module to make it work as a clone, the better -- this involves no code change, just a file name change, which is something a non-coder can handle.