Parameter Error

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.
Locked
omn3s
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu Aug 14, 2008 12:46 am

Parameter Error

Post by omn3s » Thu Aug 14, 2008 9:23 pm

So I looked up how to add parameters in the joomla wiki, and here's the code I'm using:
<?php if ($this->params->get( 'front' )){ ?>content<?php }else{ ?>pagecontent<?php } ?>


However it's throwing me this error:
Fatal error: Using $this when not in object context in /home/test/public_html/joomla/templates/test/index.php on line 45

What's the correct syntax for using a parameter?

Gergo Erdosi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4031
Joined: Sat Nov 11, 2006 9:34 pm
Location: Hungary

Re: Parameter Error

Post by Gergo Erdosi » Thu Aug 14, 2008 9:27 pm

Could you please describe which parameters would you like to get?

omn3s
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu Aug 14, 2008 12:46 am

Re: Parameter Error

Post by omn3s » Thu Aug 14, 2008 9:33 pm

I created the parameters...they're in the xml file and i created a params.ini file

<params>
<param name="front" type="radio" default="1"
label="Front Page" description="decides if its the front page.">
<option value="0">hide</option>
<option value="1">show</option>
</param>
</params>

Gergo Erdosi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4031
Joined: Sat Nov 11, 2006 9:34 pm
Location: Hungary

Re: Parameter Error

Post by Gergo Erdosi » Fri Aug 15, 2008 8:27 am

But what's this? A module? If yes, you can access the parameters like this:

Code: Select all

function yourmodule( $params ) {
  $front = $params->get('front');
}


Locked

Return to “Joomla! Coding 101”