Is there a way in plates php where I can make a template in a controller but render it using another controller. Say I have two controllers. HeaderController and a SearchController.
SearchController
class Search extends \system\core\BaseController
{
public function Index()
{
$data['text_search'] = 'Search..';
// This $this->template->render down below is what I don't want now
// okay asign the data but do not display the template yet
echo $this->template->render('common/search', $data);
}
}
The dummy SearchController should assign $data to the template search.tpl but not render/display the template.
This is where I will be calling the above controller
HeaderController
class HeaderController extends \system\core\BaseController
{
public function Index()
{
// Some codes
// Call / load the SearchController and asign it to $data['search']
$data['search'] = $this->load->controller('common/SearchController');
// and then pass all $data and render/display it.
echo $this->template->render('common/header', $data);
}
}
Is there a way of doing it?
The issue actually comes from the fact, that you are using
echowithin your class. If your "controllers" (well, they actually seem to be a combination of view and controller) were toreturneither the content orResponseclass instance, then you problem should disappear.