Question

I'm porting a Joomla 1.6 component to 3.2. In 1.6 I was able to read the components parameters defined via config.xml in a view of the component. In 3.2 the parameters are empty since the value $imagepath is always set to 'impossibru!'.

This is the code I use for my view:

<?php

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();

jimport( 'joomla.application.component.view' );

class BooomViewGame extends JViewLegacy
{
    function display($tpl = null)
    {
        var_dump(JComponentHelper::getComponent('com_booom')); //debug

        $params =& JComponentHelper::getParams('com_booom');
        var_dump($params);  //debug

        // Read the path parameter.
        $imagepath = $params->get('imagepath', 'impossibru!');

        // Make the path available on the template.
        $this->assignRef('imagepath', $imagepath);

        [some other stuff]
        parent::display($tpl);
    }
}
?>

This is the code of my config.xml defining the components parameters:

<?xml version="1.0" encoding="utf-8"?>
<config>
    <fieldset name="component">
        <field name="imagepath" type="text" default="images" label="Image path" description="Path to images of the game."/>
    </fieldset>
</config>

The output of the var_dump()s is as follows:

object(stdClass)#119 (4) { ["id"]=> string(5) "10004" ["option"]=> string(9) "com_booom" ["params"]=> object(JRegistry)#111 (1) { ["data":protected]=> object(stdClass)#118 (0) { } } ["enabled"]=> string(1) "1" }

object(JRegistry)#111 (1) { ["data":protected]=> object(stdClass)#118 (0) { } } 

As you can see the JParameter object does not contain any values. I can see and set the parameter within the configuration part of the joomla backend, though! Any idea?

Was it helpful?

Solution

The parameters aren't available in the views until you go to the configuration of the component in Joomla and click on the save button.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top