1
eikke
xoopsModuleConfig in search
  • 2004/1/27 9:54

  • eikke

  • Just popping in

  • Posts: 40

  • Since: 2004/1/15


Hija.
I'm writing a module, and implemented a basic search functionality, which gets its results from a remote server (I mean, it gets the results from a remote server, and includes them in the 'search results' of the standard XOOPS search).
To get these remote results one needs a sort of password, and a userid.
First I hardcoded these values in include/search.inc.php, but I want them to be configured from within the admin panel, using the standard XOOPS configuration possibilities ('Preferences').
The 'Preferences' thing is working, but I cannot use the results in my search function I did it like this:
function mysearchfunction(blablabla) {
    global 
$xoopsModuleConfig;
    
//blablabla
    
soSomeSearchFunction($querystring[0], $xoopsModuleConfig['pass']);
}

If I print_r xoopsModuleConfig, nothing is desplayed, and the search functionality doesnt work either. Of course this isn't my real code, just a sample of my problem.

Is there any way I can solve this?

Thanks, Ikke

2
eikke
xoopsModuleConfig in search and block
  • 2004/1/28 8:31

  • eikke

  • Just popping in

  • Posts: 40

  • Since: 2004/1/15


I searched the forums once more, and found out this question has been asked twice or something, both without a result.
I really need to get access to $xoopsModuleConfig, now both in blocks/block.php, and in include/search.inc.php, twice for the same reason.
Isnt there any way to access it? I dont think I can query the database directly, and thats not a good solution either.
Of course I could put some variables in a php file, maybe even define()s, and include it everytime. But thats not a nice solution either.
The preferences capabilities of XOOPS are great, if I could access the settings

Thanks!!!

3
GIJOE
Re: xoopsModuleConfig in search and block
  • 2004/1/28 8:57

  • GIJOE

  • Quite a regular

  • Posts: 265

  • Since: 2003/8/13


Quote:

eikke wrote:
Isnt there any way to access it? I dont think I can query the database directly, and thats not a good solution either.

Why do you think so?
my modules - piCal and myAlbum-P - get configs from xoops_config table directly, if $xoopsModuleConfig is no more usable.

I think this is good solution because XOOPS core does not offes $xoopsModuleConfig to blocks/search callbacks.

a good program is a better working proram.

4
eikke
Re: xoopsModuleConfig in search and block
  • 2004/1/28 10:02

  • eikke

  • Just popping in

  • Posts: 40

  • Since: 2004/1/15


So it is not possible. Thanks, now I know what to do: get it from the DB.
I just wanted to know wether it was possible, because if it was, it's always better to use the method the framework provides, isnt it?
Ok, now up to search how XOOPS stores preferences :)

Thanks for the information!!!

5
eikke
Re: xoopsModuleConfig in search and block
  • 2004/1/28 16:32

  • eikke

  • Just popping in

  • Posts: 40

  • Since: 2004/1/15


Got another issue now: Im trying to do this in a block.
I made a file modules/mymodule/include/config.inc.php, I include it in blocks/block.php.
Now this is what I have in config.inc.php:
function getConfig($name){
        global 
$xoopsModule;

        if(!isset(
$name) || $name=='') return null;

        
$xoopsDB=& Database::getInstance();

        
$sql="SELECT conf_value FROM ".$xoopsDB->prefix('config')." WHERE conf_modid=".$xoopsModule->mid()." AND conf_name='".$name."' LIMIT 1";

        
$res=$xoopsDB->query($sql);
        list(
$ret)=$xoopsDB->fetchRow($res);

        return 
$ret;
}

This function does what it is told to do, except... one problem: the module id it gets is the one of that on the front page, not the one of the module providing the block (I get 14, should be 10).
So I removed that conf_modid thing, and search only for the conf_name. I hope that one is unique... but it could be otherwise :( Any way to solve this?

6
Mithrandir
Re: xoopsModuleConfig in search and block

try this:
$module_handler =& xoops_gethandler('module');
//Replace 'mymodule' with the name of your module
$module =& $module_handler->getByDirname('mymodule');

$config_handler =& xoops_gethandler('config');
$moduleConfig =& $config_handler->getConfigsByCat(0$module->getVar('mid'));

You should now be able to use the configuration settings as $moduleConfig.

7
eikke
Re: xoopsModuleConfig in search and block
  • 2004/1/28 16:52

  • eikke

  • Just popping in

  • Posts: 40

  • Since: 2004/1/15


You are my hero. Thanks a lot!!!

Login

Who's Online

106 user(s) are online (75 user(s) are browsing Support Forums)


Members: 0


Guests: 106


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