How do I access the Global configuration parameters? Topic is solved

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
djcoder

How do I access the Global configuration parameters?

Post by djcoder » Fri Mar 21, 2008 8:46 am

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?

erdsiger
Joomla! Intern
Joomla! Intern
Posts: 72
Joined: Sat Nov 11, 2006 9:34 pm
Location: Hungary

Re: How do I access the Global configuration parameters?

Post by erdsiger » Sat Mar 22, 2008 6:51 pm

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;
Gergo Erdosi


Post Reply