플러그인을 사용하여 프로그래밍 방식으로 템플릿을 설정하는 방법
문제
사용자 정의 플러그인을 사용하여 백엔드에 설정된 템플릿을 어떻게 변경할 수 있나요?
나는 사용을 제안하는 다른 솔루션이었습니다
$doc= JFactory::getDocument();
$doc->setTemplate("my_tempalte_name");
작동하지 않았습니다.
해결책
줌라 3.2.+ 당신은 다음을 활용할 수 있습니다 JApplicationSite::setTemplate
방법.
이것을 트리거되는 시스템 플러그인에 넣어야 합니다. onAfterInitialise
.
public function onAfterInitialise()
{
$app = JFactory::getApplication();
// We want to change the template just on the FE
if ($app instanceof JApplicationSite)
{
$template = $app->getTemplate(); //use just debugging
var_dump($template); //use just debugging
// Set the new template and style params
$app->setTemplate('protostar', null);
$template = $app->getTemplate(); //use just debugging
var_dump($template); //use just debugging
}
}
서명 JApplicationSite::setTemplate
는 다음과 같습니다:
/**
* Overrides the default template that would be used
*
* @param string $template The template name
* @param mixed $styleParams The template style parameters
*
* @return void
*
* @since 3.2
*/
public function setTemplate($template, $styleParams = null)
제휴하지 않습니다 StackOverflow