1

This might a simple question, I've Model State variable set in my Model. When I "print_r" it in view. It provides following output:

JObject Object
(
    [_errors:protected] => Array
        (
        )

    [task] => 
    [request.id] => 3
    [params] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [path] => /media/com_helpdesk/files/
                )

            [separator] => .
        )

)

I can access 'task', 'params' variable in my view.html.php as follows:

echo $this->get('State')->params

my question is, How can I access "request.id" variable in similar way.

i.e. echo $this->get('State')->request.id

Above is (of course) not working due to additional ". (dot)".

Please note that this question is not duplicate of From the model, how I can access the data retrieved in the view? as I am trying to print variable with "dot" operator

1 Answer 1

2

You should use get function of the state object (object of JObject class)

$state = $this->get('State');
$requestId = $state->get('request.id', 0);

second parameter is default value to return in case no value exist in state object with given first parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.