Jamie
Jamie

Reputation: 379

How do I echo custom article parameters in Joomla

I'm trying to create a simple text field that can be optionally shown on a Joomla article.
At the moment I have created 2x custom article params (viewable and quick_summary)

administrator > components > com_content > models > article.xml

<params group="advanced">
<param name="viewable" type="list" default="no" label="Viewable" description="">
<option value="no">No</option>
<option value="yes">yes</option>
</param>
<param name="quick_summary" type="textarea" rows="10" cols="30" 
    label="Summary" description="Summary" />
<param type="spacer" />
...
</params>

In the template file
To have the quick_summary show depending on the status of viewable I have used the following:

<?php 
if ($this->params->get('viewable') == "yes") {
echo $this->params->get('quick_summary');
}
?>

Any help hugely appreciated

Upvotes: 0

Views: 1321

Answers (1)

Gaurav
Gaurav

Reputation: 28775

USe

$htmlArray = $this->params->renderToArray('nameSpace','groupName');

This will return html of all parameters of groupName, as array. Then echo them using for loop or using index.

echo $this->params->render('nameSpace','groupName');

This will echo the html of all parameters of GroupName

Upvotes: 2

Related Questions