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


PHP modResource::getTemplateVarCollection方法代碼示例

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


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

示例1: getTemplateVariables

 /**
  * Get all the Template Variables for this Resource
  * @return void
  */
 public function getTemplateVariables()
 {
     if (method_exists('modResource', 'getTemplateVarCollection')) {
         $tvObjs = modResource::getTemplateVarCollection($this->resource);
     } else {
         $tvObjs = $this->_getTemplateVars();
     }
     $tvs = array();
     $categories = array();
     /** @var modTemplateVar $tv */
     foreach ($tvObjs as $tv) {
         if ($tv instanceof modTemplateVar) {
             $tvArray = $tv->toArray();
             if (!empty($categories[$tvArray['category']])) {
                 $tvs[$categories[$tvArray['category']]][] = $tv;
             } else {
                 if ($tvArray['category'] == 0) {
                     $tvs[$this->modx->lexicon('uncategorized')][] = $tv;
                 } else {
                     $cat = $tv->getOne('Category');
                     if ($cat instanceof modCategory) {
                         $categories[$tvArray['category']] = $cat->get('category');
                         $tvs[$categories[$tvArray['category']]][] = $tv;
                     }
                 }
             }
         }
     }
     $list = array();
     if (count($tvs) > 0) {
         $this->modx->loadClass('hmTvInputRenderer', $this->hm->config['classesPath'], true, true);
         $renderer = new hmTvInputRenderer($this->hm);
         foreach ($tvs as $categoryName => $categoryTemplateVariables) {
             $tvList = array();
             /** @var modTemplateVar $tv */
             foreach ($categoryTemplateVariables as $tv) {
                 $tvList[] = $renderer->render($tv->get('display'), $tv);
             }
             $list[] = $this->hm->getTpl('fields/tvs/category', array('name' => $categoryName, 'collapsed' => !isset($notFirst) && count($tvs != 1) ? 'data-collapsed="false"' : 'data-collapsed="true"', 'tvs' => implode("\n", $tvList)));
             // This makes sure the first section is opened if there are > 1 sections
             $notFirst = true;
         }
         unset($notFirst);
     }
     $this->setPlaceholder('tvs', implode("\n", $list));
 }
開發者ID:rossng,項目名稱:HandyMan,代碼行數:50,代碼來源:update.class.php


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