Reputation: 8424
I am trying to add a view that I made (a table) to another view that I need to appear again. How can I do this? Actually I am trying to add a view within another view using theloadtemplate function.
This is what I type inside the view, but it does't seem to work, can anyone help? The message I get is the following
Layout default_reports not found
<div>
<?php $jinput = JFactory::getApplication()->input;
$jinput->set('view', 'reports');
echo $this->loadTemplate("reports");
$jinput->set('view', 'master');?>
</div>
But the view is there...
Upvotes: 4
Views: 6246
Reputation: 13948
If you want to be able to load "layouts" from another "view" in the current view.html.php
file, then you can do so as below.
$this->addTemplatePath(JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'anotherview' . DIRECTORY_SEPARATOR . 'tmpl');
$this->setLayout('layoutfromanotherview');
Upvotes: 2
Reputation: 884
Using the loadTemplate
function, we call only the layout inside the view.
We concatenate two or more layout using the loadtemplate inside the following view.
By default joomla, it call the layout by a prefix as default_
. So we have to create a layout as reports means filename as default_reports.php
but we need to call the layout as you have mentioned
echo $this->loadTemplate("reports");
Upvotes: 11