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...
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");
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');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With