Greetings,
I’m new to module development so maybe this is obvious to the more experienced. I want to simply use the main site url as a default value in a module if nothing else is selected. In an Exp Eng template it would just be site_url in curly brackets. There is this constant reference here… http://ellislab.com/expressionengine/user-guide/development/constants.html
But strangely it has constants for seemingly everything BUT the site url.
Is there a way to do this?
Thanks, Bob.
Yes, Bhashkar is right.
A lot of the time I find myself switching back and forth between Codeigniter Docs and EE Docs.
See heading “Fetching Config Items” on this page: http://ellislab.com/codeigniter/user-guide/libraries/config.html
Codeigniter will be $this->config->item, where EE will always be $this->EE->config->item
Thanks Bhashkar. That was what I was looking for. Also, Bransin, the lack of a constant for compatibility with Multiple Site Manager makes complete sense to me.
I tried adding the line of code to the constructor function but I must be doing something wrong with the coding. This leads me to another question about how best to create “global” values within Exp Eng modules for use by any function in the module. Following is the construct function…
/**
* FUNCTION - Construct
*/
function __construct()
{
$this->EE =& get_instance() ;
$site_url = $this->EE->config->item('site_url') ;
} // end function constructHowever, if I use this->$site_url or this->EE->$site_url something goes wrong with the code. I tried the following…
$site_url = $this->EE->site_url ;
$site_url = $this->site_url ;Both of the above return an empty value.
Thanks, Bob.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.