diff --git a/application/core/LSETwigViewRenderer.php b/application/core/LSETwigViewRenderer.php index e2f6b042790..9dd45baffb2 100644 --- a/application/core/LSETwigViewRenderer.php +++ b/application/core/LSETwigViewRenderer.php @@ -135,21 +135,27 @@ public function renderQuestion( $sView, $aData) } } + public function renderTemplateForTemplateEditor($sView, $aDatas, $oEditedTemplate) + { + $oTemplate = $this->getTemplateForView($sView, $oEditedTemplate); + $line = file_get_contents($oTemplate->viewPath.$sView); + $result = $this->renderTemplateFromString( $line, $aDatas, $oTemplate, true); + return $result; + } public function renderTemplateFromFile($sView, $aDatas, $bReturn) { - $oTemplate = $this->getTemplateForView($sView); + $oRTemplate = Template::model()->getInstance(); + $oTemplate = $this->getTemplateForView($sView, $oRTemplate); $line = file_get_contents($oTemplate->viewPath.$sView); - $result = $this->renderTemplateFromString( $line, $aDatas, $bReturn); + $result = $this->renderTemplateFromString( $line, $aDatas, $oTemplate, $bReturn); if ($bReturn){ return $result; } } - private function getTemplateForView($sView) + private function getTemplateForView($sView, $oRTemplate) { - $oRTemplate = Template::model()->getInstance(); - while (!file_exists($oRTemplate->viewPath.$sView)){ $oMotherTemplate = $oRTemplate->oMotherTemplate; @@ -170,11 +176,10 @@ private function getTemplateForView($sView) * @param array $aDatas Array containing the datas needed to render the view ($thissurvey) * @param boolean $bReturn Should the function echo the result, or just returns it? */ - public function renderTemplateFromString( $line, $aDatas, $bReturn) + public function renderTemplateFromString( $line, $aDatas, $oRTemplate, $bReturn=false) { $this->_twig = $twig = parent::getTwig(); $loader = $this->_twig->getLoader(); - $oRTemplate = Template::model()->getInstance(); $loader->addPath($oRTemplate->viewPath); Yii::app()->clientScript->registerPackage( $oRTemplate->sPackageName ); diff --git a/templates/default/views/subviews/survey/question.twig b/templates/default/views/subviews/survey/question.twig index 7ee83b200c1..bc1f632300c 100644 --- a/templates/default/views/subviews/survey/question.twig +++ b/templates/default/views/subviews/survey/question.twig @@ -17,7 +17,7 @@ It will render a question. It's included in the for loop in group.twig Here, you have access to the array aQuestion that contains the data of the current question. - To see what's inside aQuestion, turn debug mode on, and copy the following line to the end of this file: + To see what's inside aQuestion, turn debug mode on, and copy the following line to the end of this file: {{ dump(aQuestion) }} All content of aQuestion itself is generated from qanda_helper. @@ -28,10 +28,15 @@ {# Showing question code/number is a survey level setting, so it's inside the array aSurveyInfo #} -{% set aShow = aSurveyInfo.aShow %} +{% set aShow = aSurveyInfo.aShow %} +{% set sClasses = '' %} + +{% if not (aQuestion.templateeditor) %} + {% set sClasses = getAllQuestionClasses( aQuestion.qid ) %} +{% endif %} -
+