I have been searching for my problem of sending data from a sub-controller to a model in MVC Joomla component and I have been searching out for my problem in google and got this link but it is giving me the blank results. I have tried so many tutorials but it is not working.
My Sub-Controller send.php Code is below
<?php
/**
* @package Joomla.Administrator
* @subpackage com_helloworld
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Hello World Component Controller
*
* @since 0.0.1
*/
class HostingControllerSend extends JControllerLegacy
{
public function save_ratings(){
$data = 'I am Data from Send Controller'; //get data from front end form
$model = $this->getModel('Receive'); //load UpdateRatings model
$model->set_data($data); //update setter function of model
$res=$model->getData(); // retrieve getter function
//print_r($res);
}
}
My Model receive.php code
<?php
/**
* @package Joomla.Administrator
* @subpackage com_helloworld
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Hello World Component Controller
*
* @since 0.0.1
*/
class HostingModelReceive extends JModelLegacy
{
public $data;
public function getData(){
$data=$this->data;
return $data;
}
public function set_data($data){
$this->data=$data;
}
}
My view
<?php
/**
* @package Joomla.Administrator
* @subpackage com_helloworld
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* HTML View class for the HelloWorld Component
*
* @since 0.0.1
*/
class HostingViewReceive extends JViewLegacy
{
/**
* Display the Hello World view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*/
function display($tpl = null)
{
// Assign data to the view
$this->msg = $this->get('Data');
// Display the view
parent::display($tpl);
}
}
Any help would be appreciated. Kind Regards!