2

I'm trying to add some external information to a component, and it retrieves the data in view.html.php. Once it is retrieved, how can I use it the model? I've tried as many of the usual variables that I can think of, but no success. I can see that it's buried down inside $this (which is an extension of JModelAdmin), but can find a way to get to it.

example\view.html.php

public function display($tpl = null) {
    $this->state    = $this->get('State');
    $this->item     = $this->get('Item');
    $this->form     = $this->get('Form');
    $this->MyInfo   = $this->get(MyInfo);  // Use $this->item to get my info

models\example.php:

public function getItem($pk = null) {
    if (!$item = parent::getItem($pk))
    {
        throw new Exception('Failed to load item');
    }
    return $item;
}

public function getMyInfo($pk = null)
{
    // Need some of the data from `$this->item` already retrieved in function `display`
    // Do some SQL here

    return $mydata;
}

1 Answer 1

2

Try the parent from your get function

public function getMyInfo($pk = null)
{
   $myItem = parent::getItem($pk);
   echo $myItem->myfieldname;
   .
   .
   .

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.