PDA

Zobacz pełną wersję : Joomla3, Moduł, JModuleHelper::getLayoutPath



Craft
17-08-2013, 23:00
Witam,

Piszę moduł pod Joomla 3.1.5 i nie mogę ustawić aby skorzystał z innego layoutu.



defined('_JEXEC') or die;

$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));
$blok = htmlspecialchars($params->get('blok'));

$input = new JInput;
$check = $input->get('check', null);

if($check==null) {
if($blok==1) {
require JModuleHelper::getLayoutPath('mod_calculator', $params->get('layout', 'default'));
}
} else {
require_once __DIR__ . '/helper.php';
$status = ModCalculatorHelper::sendMail($params);

if($status==TRUE) {
try {
require JModuleHelper::getLayoutPath('mod_calculator', $params->get('layout', 'send_mail_success'));
} catch(Exception $e) {
echo 'Message: ' .$e->getMessage();
}
echo '<h1>Mail został wysłany</h1>';
} else {
require JModuleHelper::getLayoutPath('mod_calculator', $params->get('layout', 'send_mail_fail'));
}
}

Cały czas pokazuje layout default, mimo że wypisuje tekst na ekranie "Mail został wysłany"

Co ciekawe jak zmieniłem nazwę pliku default.php to teraz wyskakuje komunikat:


Warning: require(/home/expnet/public_html/joomla3.vipserv.org/modules/mod_calculator/tmpl/default.php): failed to open stream: No such file or directory in/home/expnet/public_html/joomla3.vipserv.org/modules/mod_calculator/mod_calculator.php on line 19



Fatal error: require(): Failed opening required '/home/expnet/public_html/joomla3.vipserv.org/modules/mod_calculator/tmpl/default.php' (include_path='.:/home/expnet/pear/php/:/usr/lib/php/') in/home/expnet/public_html/joomla3.vipserv.org/modules/mod_calculator/mod_calculator.php on line 19


A linia 19 to:


require JModuleHelper::getLayoutPath('mod_calculator', $params->get('layout', 'send_mail_success'));


Dodam, że w katalogu tmpl jest plik send_mail_success.php

Będę wdzięczny za pomoc.

Pozdrawiam,
Łuaksz

- - - Updated - - -

Rozwiązanie problemu:
1. Poprawny kod dla przekierowania na inny layout to


require JModuleHelper::getLayoutPath($module, $layout= 'default');