1
phatjew
Re: XOOPS Dev Team: Would it be hard to propagate module name in all reference to the module?
  • 2004/3/26 15:37

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:

krayc wrote:

I'd happy to test anything you have, and/or start documenting what you and others are learning from this thread.


Hey, I might just take you up on that offer. One of the reasons I haven't released the module yet is that I don't want to give something to the community that is incomplete and buggy. If there were people interested in beta testing a VERY HIGHLY CONFIGURABLE module that could be used for pretty much any kind of content, I could probably have something ready in a week or so (depending on how busy I am at "real" work).



2
phatjew
Re: XOOPS Dev Team: Would it be hard to propagate module name in all reference to the module?
  • 2004/3/25 17:32

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:

Herko Coomans wrote:
And cloning modules is good, but isn't it the same as having multiple organisable instances of modules running? And that requires only adding an extra field to the modules, a new unique ID by which you can groups your content items from that particular module, right? Sort of like categories, but a little different.


That's true, if you want the modules to be pretty much identical. My idea with creating a clone is that the module I am writing has a BUNCH of configuration options, including what fields to display, what fields to make searchable, what the module-specific categories of content are, etc. Not to mention templates, if you wanted them to be different for each instance of the module.

I have this grand vision of being able to use this module for all kinds of different content on the same site. I'll hopefully be releasing it soon (within a month?), and you'll be able to see what I mean.



3
phatjew
Re: XOOPS Dev Team: Would it be hard to propagate module name in all reference to the module?
  • 2004/3/23 15:12

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:

Herko Coomans wrote:
It would work, but how would you add classes for your own modules? If they're already in a file, you can't append them to the file. If your module depends on some non-core classes, how can you insure they're atually available? This requires a central class library that will grow and grow, not making the system any faster.

Herko


I guess that's the problem exactly. You'd have to manually copy your module's classes into the central class library (which already exists, right?). This, of course, means that if every module worked this way, that central class library would become unmanageably large.

One solution that I might go with right now is not to use classes at this point. I understand all the benefits of classes and object orientation (I'm a C++ programmer in real life), but it seems to me that it makes cloning a module just about impossible without a whole lot of search and replace in the code, which is always very dangerous if you are worried about stability. If all of the language variables and SQL calls in my module use the realpath(_FILE_) convention or something like it (as described above), there won't be any problems with having blocks from multiple clones on the same page.


But please tell me if anyone thinks this is a Really Bad Idea, and if it is, what direction we might take in the future to allow the development of modules that are fully clonable.



4
phatjew
Re: XOOPS Dev Team: Would it be hard to propagate module name in all reference to the module?
  • 2004/3/23 13:58

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:
The alternative is writing so all clones read the *exact* same files (not just the same contents in the same relative location, but the SAME file; otherwise 'include_once' won't work), all from a SINGLE shared directory. Not sure how you would do this in a cloneable way though.


If all of the functions were encapsulated in classes, with $VarPrefix and/or $dirname as function paramterers wherever needed, then the classes themselves could be put in the main XOOPS classes directory, and not within individual modules.

Would this work?



5
phatjew
Re: XOOPS Dev Team: Would it be hard to propagate module name in all reference to the module?
  • 2004/3/23 3:37

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


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.




6
phatjew
Re: XOOPS Dev Team: Would it be hard to propagate module name in all reference to the module?
  • 2004/3/22 19:59

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:
If you have some examples on how to use it with the database, commenets, searches, notification etc.. please post them here.


Yes, absolutely.

I notice you are almost at post #100. Congratulations! Soon, you won't just be "popping in"!




7
phatjew
Re: XOOPS Dev Team: Would it be hard to propagate module name in all reference to the module?
  • 2004/3/22 18:50

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Daigoro, this is really good stuff. I am going to try to implement it in my module (since I'm rewriting it right now anyway), and I'll let you know all of the problems/solutions that I come up with. Thanks for posting your code.



8
phatjew
Re: Anyone have a script to reload modules?
  • 2004/3/22 18:44

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:
I do know I only seem to have to do this when there are template changes. But it's still a lot.


I ran into this, too, so I wrote a function called recompileTemplate() which I then call to reload a page's template every time it is requested. Obviously, you want to comment out this call once development is done, but it has saved me hours, at least. Take a look at this
thread about recompiling templates



9
phatjew
Re: XOOPS Dev Team: Would it be hard to propagate module name in all reference to the module?
  • 2004/3/19 20:08

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Two questions:

1. I have two files where constants reside in the language/english directory, modinfo.php and main.php.

The following line is in modinfo.php:

define("_MI_PJREVIEWS_NAME","Reviews");

in my main.php, I want to do this:

define("_XD_PJREVIEWS_DOCS",_MI_PJREVIEWS_NAME);

But this does not work. Why can't one file see the other, if these are all defined globally? Does this mean that unless you specifically include a language constants file, it won't conflict with another one? And doesn't THAT mean that I could have two language constants in different "cloned" modules named the same with no conflict?


2.What do I have to do to get these to work in the main.php language file:
define("_XD_PJREVIEWS_DOCS",$module->getVar('name'));

or

define("_XD_PJREVIEWS_DOCS",$xoopsModule->name());



10
phatjew
Re: XOOPS Dev Team: Would it be hard to propagate module name in all reference to the module?
  • 2004/3/19 14:04

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:
However, most of this is irrelevant because most people write their functions with hard-coded dirname-dependent things.


I'm trying to avoid exactly this. I figure that if I write my functions in a generic fashion (using 'dirname' where appropriate, etc.), I shouldn't have any problems. What's the fastest way to access the current dirname? I know there is more than one way to do it, but if I am going to access it repeatedly I want to do so as efficiently as possible. The example above uses:

$module->getVar('dirname')


but, if I'm using a language constant for the dirname ,wouldn't it be faster to just use that constant?


jurgis, I completely agree on grep. I've used it on *nix for years, and love it. Thanks for the link to the windows version -- I didn't even know it existed.




TopTop
(1) 2 3 4 ... 6 »



Login

Who's Online

151 user(s) are online (101 user(s) are browsing Support Forums)


Members: 0


Guests: 151


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits