Page 1 of 1

How do I access the Global configuration parameters?

Posted: Fri Mar 21, 2008 8:46 am
by djcoder
I am building a component on Joomla! 1.5 and have two questions:
1. How do I access global configuration parameters?
I tried the following from within the Model

Code: Select all

	global $mainframe;
	$params = &$mainframe->getParams();
but it did not work as I had anticipated. Object seemed empty.......Maybe I did not call it properly.

2. How do I compare the global parameters with the parameters of the article itself. (best practices)
I know they are stored in the #__content.attribs, but is there already a function in the framework to load the into an array or, preferably, an object? Or should I use some combination of explode() and regular expressions?

Re: How do I access the Global configuration parameters?

Posted: Sat Mar 22, 2008 6:51 pm
by erdsiger
Welcome to the forum!
djcoder wrote:1. How do I access global configuration parameters?
Use this code to get the global configuration parameters:

Code: Select all

global $mainframe;
$sitename = $mainframe->getCfg( 'sitename' );
djcoder wrote:2. How do I compare the global parameters with the parameters of the article itself.
You didn't mention which global parameters you want to get (site or article). With the above mentioned code you get the site global parameters. Try this code to get the global article parameters:

Code: Select all

global $mainframe;
$params = $mainframe->getParams('com_content');
To get the current article parameters, use this code:

Code: Select all

$article	= $this->get('Article');
$aparams = $article->parameters;