當前位置: 首頁>>代碼示例>>PHP>>正文


PHP tpl::parseTemplate方法代碼示例

本文整理匯總了PHP中tpl::parseTemplate方法的典型用法代碼示例。如果您正苦於以下問題:PHP tpl::parseTemplate方法的具體用法?PHP tpl::parseTemplate怎麽用?PHP tpl::parseTemplate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tpl的用法示例。


在下文中一共展示了tpl::parseTemplate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getSurveyContent

 /**
  * getSurveyContent
  * Render the actual survey question for the specified form id that passed .
  *
  * @return string rendered template
  *
  * @param int    $formId   The id of the survey to get the content for.
  * @param tpl 	 $tpl	   This is the actual template system parsed from the front end
  */
 public function getSurveyContent($surveyId, $tpl)
 {
     // give the form an action to handle the submission
     // $tpl->Assign('action', 'admin/index.php?Page=Addons&Addon=surveys&Action=Submit&ajax=1&formId=' . $surveyId);
     $success_message = IEM::sessionGet('survey.addon.' . $surveyId . '.successMessage');
     if ($success_message) {
         IEM::sessionRemove('survey.addon.' . $surveyId . '.successMessage');
         $tpl->Assign('successMessage', $success_message);
         return $tpl->ParseTemplate('survey_success');
     }
     $tpl->Assign('action', 'surveys_submit.php?ajax=1&formId=' . $surveyId);
     // check for valid ID
     if (!isset($surveyId)) {
         return;
     }
     require_once 'widgets.php';
     $widgets_api = new Addons_survey_widgets_api();
     $loadRes = $this->Load($surveyId);
     if ($loadRes === false) {
         echo 'invalid form id';
         return;
     }
     $surveyData = $this->GetData();
     $widgets = $this->getWidgets($this->id);
     // and if there are widgets
     // iterate through each one
     $widgetErrors = array();
     if ($widgets) {
         $widgetErrors = IEM::sessionGet('survey.addon.' . $surveyId . '.widgetErrors');
         foreach ($widgets as $k => &$widget) {
             if ($widget['is_visible'] == 1 || $widget['type'] == 'section.break') {
                 // $widget->className = Interspire_String::camelCase($widget->type, true);
                 // Getting error from form..
                 $widget['className'] = 'Widget_' . str_replace('.', '_', $widget['type']);
                 $widgets_api->SetId($widget['id']);
                 $widget['fields'] = $widgets_api->getFields(false);
                 // if there are errors for this widget, set them
                 if ($widgetErrors && count($widgetErrors[$widget['id']]) > 0) {
                     $widget['errors'] = $widgetErrors[$widget['id']];
                 }
                 // randomize the fields if told to do so
                 if ($widget['is_random'] == 1) {
                     shuffle($widget['fields']);
                 }
                 // tack on an other field if one exists
                 if ($otherField = $widgets_api->getOtherField()) {
                     $otherField['value'] = '__other__';
                     $widget['fields'][] = $otherField;
                 }
                 // if it is a file widget, then grab the file types
                 if ($widget['type'] == 'file') {
                     $widget['fileTypes'] = preg_split('/\\s*,\\s*/', $widget['allowed_file_types']);
                     $widget['lastFileType'] = array_pop($widget['fileTypes']);
                 }
                 // assign the widget information to the view
                 $tpl->Assign('widget', $widget);
                 // render the widget template
                 $widget['template'] = $tpl->parseTemplate('widget.front.' . $widget['type'], true);
             } else {
                 unset($widgets[$k]);
             }
         }
         // clear the widget errors session variable
         IEM::sessionRemove('survey.addon.' . $surveyId . '.widgetErrors');
     }
     // assign the form, widget and widget-field data to the template
     $tpl->Assign('errorMessage', IEM::sessionGet('survey.addon.' . $surveyId . '.errorMessage'));
     $tpl->Assign('successMessage', IEM::sessionGet('survey.addon.' . $surveyId . '.successMessage'));
     $tpl->Assign('survey', $surveyData);
     $tpl->Assign('widgets', $widgets);
     // unset the message that was set, so it doesn't get displayed again
     IEM::sessionRemove('survey.addon.' . $surveyId . '.errorMessage');
     IEM::sessionRemove('survey.addon.' . $surveyId . '.successMessage');
     //return $this->template->parseTemplate('form', true);
     return $tpl->ParseTemplate('survey');
 }
開發者ID:hungnv0789,項目名稱:vhtm,代碼行數:85,代碼來源:surveys.php


注:本文中的tpl::parseTemplate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。