Ich möchte mir ein schlankes Modul erstellen, mit welchem ich Komponenten-Ansichten in Modulpositionen anzeigen lassen kann. Ich habe mir dazu bereits das Plugin Components Anywhere angeschaut. Jedoch müsste sowas doch auch schlanker möglich sein...
Hier habe ich einen Beitrag gefunden, welcher genau mein Anliegen beschreibt:
https://joomla.stackexchange.c…omponent-view-in-a-module
Folgender Code (basierend auf dem Code aus obigem Link) für eine Formular-Ansicht (ALFContact Komponente) liefert mir den Fehler (kompletter Call Stack im Anhang):
500 Layout „default“ nicht gefunden!
/opt/bitnami/apache2/htdocs/joomla/libraries/src/MVC/View/HtmlView.php:706
Code
// No direct access
defined('_JEXEC') or die;
$basePath = dirname(__FILE__);
$jinput = JFactory::getApplication()->input;
// Get variables from request
$option = $jinput->get('option',null);
$view = $jinput->get('view',null);
$layout = $jinput->get('layout',null);
$task = $jinput->get('task',null);
// Set component specific request variables
$myoption = $jinput->set('option', 'com_alfcontact');
$myview = $jinput->set('view', 'alfcontact');
$mylayout = $jinput->set('layout', 'default');
$mytask = $jinput->set('task', 'display');
$mymenuid = $jinput->set('Itemid', '230');
// load language files
$lang = JFactory::getLanguage();
$lang->load('com_alfcontact', JPATH_SITE);
// load component controller
if (!class_exists('AlfcontactController')) {
require_once (JPATH_SITE . '/components/com_alfcontact/controller.php');
}
$controller = new AlfcontactController();
$controller->addModelPath(JPATH_SITE . '/components/com_alfcontact/models/');
$controller->addViewPath(JPATH_SITE . '/components/com_alfcontact/views/');
$controller->setProperties(array(
'_basePath' => JPATH_SITE . '/components/com_alfcontact',
'default_view' => JPATH_SITE . '/components/com_alfcontact/views/alfcontact/tmpl',
'_path' => array(
'view' => array(
JPATH_SITE . '/components/com_alfcontact/views'
),
'model' => array(
JPATH_SITE . '/components/com_alfcontact/models'
)
)
));
// render the view
$controller->execute($jinput->get('task','display'));
// Redirect if set by the controller
$controller->redirect();
// revert request variables to previous state
if($option != null)
{
$jinput->set('option', $option);
}
if($view != null)
{
$jinput->set('view', $view);
}
if($layout != null)
{
$jinput->set('layout', $layout);
}
if($task != null)
{
$jinput->set('task', $task);
}
Alles anzeigen
Hat jemand eine Ahnung, was an diesem Code noch falsch ist?
Danke für eure Hilfe...
Manuel