Reply New Topic
2022/11/28 7:57:41

get module foldername

I'm updating iForum to be compatible with the upcoming ImpressCMS 1.5.0, and as such I need to replace the $icmsModule variable with something else. That variable is used in many cases in this way : 


When I replace it with icms::$module->getvar('dirname') the value I get back is always 'system' instead of the folder in which the iforum module resides. Any idea how I can retrieve the module folder in newer code?


Me on Ohloh

2022/12/3 10:45:17
Home away from home

Re: get module foldername

I would think that should work - I have it working like that for SimplyWiki. I have also set the module directory in the header file, which then is used to set icms::$module

Other IPF modules use some logic to determine if they are in the module

if (is_object(icms::$module) && icms::$module->getVar("dirname") == IMBLOGGING_DIRNAME) {
    // We are in the module

This puts the directory name in a constant, which is set dynamically as the module loads {module}/include/common.php

If you're in the module's preferences, you will be in the system module, technically, for most modules.

Edited by skenow on 2022/12/3 11:19:22

Steve Twitter: @skenow Facebook: Steve Kenow

2022/12/6 4:53:56

Re: get module foldername

I'll need to check out how this works in that case for iForum. It's rather old code and my first focus is to get it working on 1.5.0 without rewriting it completely.

The way you describe @skenow is not always possible, I remember from the old X days that it was sometimes possible to clone modules, and this the module needed to be aware of the folder in which it was installed. That wasn't hardcoded in a constant. Not that I think that's a good way of doing things, but I'm just saying perhaps some of that logic is also there for iForum.


Me on Ohloh

Reply New Topic extras
 Previous Topic   Next Topic
You can view topic.
You can start a new topic.
You can reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You can post without approval.