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

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:
In the cloned module, you'd probably have to make manual modifications to just include the code from the *other* module so files don't get included twice. (Or you could use 'if function_defined', 'if class_exists' to conditionally load files.) Not impossible, but also not as simple as just installing two copies of the module with different dirname.


I did not realize that classes and functions defined inside a module would be global. Is that a good idea, in general?

Regardless, absolutely you'd have to be careful since they are defined globally. Could you maybe provide examples of how to use the 'if function_defined', 'if class_exists' to conditionally load files? I would think that 'if function_NOT_defined' would be the way to go, but I don't know how to do that, either.

Also, could you use "include_once" or something like that instead?




12
phatjew
Re: "$HTTP_POST_VARS as $k" -- what is this?
  • 2004/3/17 19:18

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


So, what I am hearing is that I can simply delete these lines, and anytime I need to access $_POST data, I should just use $_POST['thingy']. OK, I will take Mithrandir's advice and not be lazy.

On a related note, if I want to send all the POST data to a function, can I just do this:

$result = doYourThingWithPOSTData($_POST);

Does that make a copy, or can I send it by reference by defining my function like this (I am a C++ programmer in real life, so this syntax could be wrong):

function doYourThingWithPOSTData(&$_POST){ . . . }


Or, is there a better way to make all current $_POST data available inside other functions and classes other than explicitly passing it? Basically, I have code that works now, but I am refactoring to make it much simpler and object-oriented. Before, everything was in index.php, but that has grown too big to manage.

Thanks for any help.



13
phatjew
"$HTTP_POST_VARS as $k" -- what is this?
  • 2004/3/17 18:16

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:
if (isset($HTTP_GET_VARS)) {
foreach ($HTTP_GET_VARS as $k => $v) {
$$k = $v;
}
}
if (isset($HTTP_POST_VARS)) {
foreach ($HTTP_POST_VARS as $k => $v) {
$$k = $v;
}
}


Forgive my ignorance, but I am modifying (rewriting) a module that has this line at the top of the index.php (and several other places). What does it do? Can I remove it and use $_POST instead, or will that cause people problems who aren't using the latest versions of PHP?



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

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


I agree that for function names, there is no reason to make a distinction between two copies of the same module -- after all, if it is truly a clone, then the same code is going to be executed.

As for two classes, that is the same. If you put your class inside your own module directory, it doesn't matter (since each clone will look at its own directory). If you put your class under the "class" directory, then you only need one copy for any number of clones, because the point of a class is that it is reusable.

I do agree, however, that blocks have to handled very carefully. Maybe just including the dirname in the name of the blocks will work. I'll be coding it over the next couple of weeks, so I'll update this thread with what I find out.



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

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:
Would the following accomplish what you want? i.e. just require a change in one place?
define("_MI_PJREVIEWS_NAME","Reviews");

define("_MI_B_LATEST", "Latest " . _MI_PJREVIEWS_NAME);
define("_MI_B_SUBMIT", "Waiting " . _MI_B_SUBMIT);


Yeah, that would make things easier. But it would still require a change to a file, rather than in a control panel. I'm trying to make renaming this module as painless as possible, since I want to have two or three instances of it on my site for very different purposes. I guess there's a limit to how much flexibility it can have, though.

Quote:
Note also that for naming your language constants, it would be better to use _MI_PJREVIEWS_B_LATEST and _MI_PJREVIEWS_B_SUBMIT instead of _MI_B_LATEST and _MI_B_SUBMIT.


Yes, thank you for reminding me. I have a bit of this kind of cleanup to do before I can safely release the module.



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

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


*bump*



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

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


This is an extremely useful thread. Quick follow-up:

Quote:
Of course, you can also write the names directly into xoops_version.php, but the recommended way is to use language constants so a user can change them at will.


I am making a module that was originally going to be for reviews, but has grown into something much more flexible. If I want to enable an ability to rename the module at will through a preferences page in the admin menu, is this possible?

In other words, currently the line in my xoops_version.php looks like this:

$modversion['name'] = _MI_PJREVIEWS_NAME;

and my language file looks like this:

define("_MI_PJREVIEWS_NAME","Reviews");

So, I have to go into the language file and physically hard code the name. Is there a way to do it programmatically? Has anyone tried this before?

It occurs to me that I will also want to change these lines:

define("_MI_B_LATEST","Latest Reviews");
define("_MI_B_SUBMIT","Waiting Reviews");

So, it isn't just one line that a user would have to change to make the whole module take a different name.

Thanks in advance for any advice.



18
phatjew
Re: Duplicating a module
  • 2003/11/26 16:01

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:

ladysham wrote:

However, when I go to install the module, I get an error message that the module news has already been created. Am I missing something in an installation file somewhere?

Thanks!

Kelly Ling



There may be at least one more line in xoops_version.php, like $modversion['name'], that needs to be changed. I don't know if the name of a module is a unique field, but it might be.

However, I'll repeat my warning that it still may not work as two differnt modules if they are still going after the same tables in the database. If you truly want the two copies to be seperate, you will have to change the SQL statements throughout the module's code, as well as the install sql file.



19
phatjew
Re: www.123ecominfo.com (Need Review on a New site)
  • 2003/11/26 14:12

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Site looks good. Just a couple of things:

1. I would move the top posters off the top of the page, too. I would definitely put that BELOW the "New Products" and "New Tools" blocks.

2. This is just personal preference, but I would also put the main navigation block on the left at the top, and the login block below it. I find it easier to navigate around sites when the main navigation is always in the same place, upper left. That's might just be me, though, and I would ask other people about that.

3. when I click on the "articles" tab, the article section comes up. However, when you look at the tabs it still looks like the "home" tab is uppermost. Usually, the tabs change to reflect where you are on the site.

In other words, when I am on the home page, the home tab should be light blue, and the others gray. When I am on the articles page, the Aticles tab should be light blue and the others gray. At least, that's how tabs usually work.



20
phatjew
Re: Duplicating a module
  • 2003/11/26 14:01

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:

chrisz wrote:
It would be great if in module installations you could define the installation directory and table names so you could use the same module for multiple sections. Just my 2 cents.

Chris


It is more complicated than that, though. Throughout the code of any given module there are SQL statements with the EXACT names of the tables used. If the tables names are dynamic, every single one of these queries would have to be rewritten to pull the table name from somewhere. Not only would that be complicated, but it could potentially slow down the whole transaction.

One possible solution is to put the table names in the xoops_version.php file that is unique to each module, and make sure that each individual copy of the module has different table names. Then, the SQL statements could be rewritten to pull the table names from xoops_version instead of being hardcoded. Again, though, this involves a lot of dev work for EACH INDIVIDUAL MODULE. There is NO WAY to do this for all modules just by changing something the XOOPS core or kernel, I believe. It has to be done on an individual module basis.




TopTop
« 1 (2) 3 4 5 6 »



Login

Who's Online

235 user(s) are online (156 user(s) are browsing Support Forums)


Members: 0


Guests: 235


more...

Donat-O-Meter

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

Latest GitHub Commits