Question

Here below is the code from the view.html.php

class ><><><><><><><>< extends JViewLegacy
{
    public $data;

    // Overwriting JView display method
    function display($tpl = null) 
    {
        // Check for errors.
        if (count($errors = $this->get('Errors'))) 
        {
            JError::raiseError(500, implode('<br />', $errors));
            return false;
        }
        $data = $this->data;            // This is having array object

        // Display the view
        parent::display($tpl);
    }
}

Here below is the code in default.php

Result View

<?php 
        echo "<pre>";
            print_r($data);
        echo "</pre>";
?>

The data in default.php is not showing any data.

Was it helpful?

Solution

To assign values from view.html.php you should use something like this:

$this->data = $data;

And in default.php you should access $data by:

print_r($this->data);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top