当前位置: 首页>>代码示例>>PHP>>正文


PHP ContentObjectRenderer::setCurrentVal方法代码示例

本文整理汇总了PHP中TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::setCurrentVal方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentObjectRenderer::setCurrentVal方法的具体用法?PHP ContentObjectRenderer::setCurrentVal怎么用?PHP ContentObjectRenderer::setCurrentVal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer的用法示例。


在下文中一共展示了ContentObjectRenderer::setCurrentVal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * Renders the TypoScript object in the given TypoScript setup path.
  *
  * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
  * @return string the content of the rendered TypoScript object
  */
 public function render()
 {
     $typoscriptObjectPath = $this->arguments['typoscriptObjectPath'];
     $data = $this->arguments['data'];
     $currentValueKey = $this->arguments['currentValueKey'];
     $table = $this->arguments['table'];
     if (TYPO3_MODE === 'BE') {
         $this->simulateFrontendEnvironment();
     }
     if ($data === null) {
         $data = $this->renderChildren();
     }
     $currentValue = null;
     if (is_object($data)) {
         $data = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getGettableProperties($data);
     } elseif (is_string($data) || is_numeric($data)) {
         $currentValue = (string) $data;
         $data = [$data];
     }
     $this->contentObjectRenderer->start($data, $table);
     if ($currentValue !== null) {
         $this->contentObjectRenderer->setCurrentVal($currentValue);
     } elseif ($currentValueKey !== null && isset($data[$currentValueKey])) {
         $this->contentObjectRenderer->setCurrentVal($data[$currentValueKey]);
     }
     $pathSegments = GeneralUtility::trimExplode('.', $typoscriptObjectPath);
     $lastSegment = array_pop($pathSegments);
     $setup = $this->typoScriptSetup;
     foreach ($pathSegments as $segment) {
         if (!array_key_exists($segment . '.', $setup)) {
             throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('TypoScript object path "' . htmlspecialchars($typoscriptObjectPath) . '" does not exist', 1253191023);
         }
         $setup = $setup[$segment . '.'];
     }
     $content = $this->contentObjectRenderer->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.']);
     if (TYPO3_MODE === 'BE') {
         $this->resetFrontendEnvironment();
     }
     return $content;
 }
开发者ID:,项目名称:,代码行数:46,代码来源:

示例2: getListContent

 /**
  * get the content for a news item NOT displayed as single item (List & Latest)
  *
  * @param	array		$itemparts : parts of the html template
  * @param	array		$selectConf : quety parameters in an array
  * @param	string		$prefix_display : the part of the TS-setup
  * @return	string		$itemsOut: itemlist as htmlcode
  */
 function getListContent($itemparts, $selectConf, $prefix_display)
 {
     if ($this->debugTimes) {
         $this->hObj->getParsetime(__METHOD__);
     }
     $limit = $this->config['limit'];
     $lConf = $this->conf[$prefix_display . '.'];
     $res = $this->exec_getQuery('tt_news', $selectConf);
     //get query for list contents
     //				debug($selectConf, $this->theCode.' final $selectConf (' . __CLASS__ . '::' . __FUNCTION__ . ')', __LINE__, __FILE__, 3);
     // make some final config manipulations
     // overwrite image sizes from TS with the values from content-element if they exist.
     if ($this->config['FFimgH'] || $this->config['FFimgW']) {
         $lConf['image.']['file.']['maxW'] = $this->config['FFimgW'];
         $lConf['image.']['file.']['maxH'] = $this->config['FFimgH'];
     }
     if ($this->config['croppingLenght']) {
         $lConf['subheader_stdWrap.']['crop'] = $this->config['croppingLenght'];
     }
     $this->splitLConf = array();
     $cropSuffix = FALSE;
     if ($this->conf['enableOptionSplit']) {
         if ($this->config['croppingLenghtOptionSplit']) {
             $crop = $lConf['subheader_stdWrap.']['crop'];
             if ($this->config['croppingLenght']) {
                 $crop = $this->config['croppingLenght'];
             }
             $cparts = explode('|', $crop);
             if (is_array($cparts)) {
                 $cropSuffix = '|' . $cparts[1] . ($cparts[2] ? '|' . $cparts[2] : '');
             }
             $lConf['subheader_stdWrap.']['crop'] = $this->config['croppingLenghtOptionSplit'];
         }
         $resCount = $this->db->sql_num_rows($res);
         $this->splitLConf = $this->processOptionSplit($lConf, $limit, $resCount);
     }
     $itemsOut = '';
     $itempartsCount = count($itemparts);
     $pTmp = $this->tsfe->ATagParams;
     $cc = 0;
     $piVarsArray = array('backPid' => $this->conf['dontUseBackPid'] ? null : $this->config['backPid'], 'year' => $this->conf['dontUseBackPid'] ? null : ($this->piVars['year'] ? $this->piVars['year'] : null), 'month' => $this->conf['dontUseBackPid'] ? null : ($this->piVars['month'] ? $this->piVars['month'] : null));
     // needed for external renderer
     $this->listData = array();
     // Getting elements
     while ($row = $this->db->sql_fetch_assoc($res)) {
         // gets the option splitted config for this record
         if ($this->conf['enableOptionSplit'] && !empty($this->splitLConf[$cc])) {
             $lConf = $this->splitLConf[$cc];
             $lConf['subheader_stdWrap.']['crop'] .= $cropSuffix;
         }
         $wrappedSubpartArray = array();
         $titleField = $lConf['linkTitleField'] ? $lConf['linkTitleField'] : '';
         // First get workspace/version overlay:
         if ($this->versioningEnabled) {
             $this->tsfe->sys_page->versionOL('tt_news', $row);
         }
         // Then get localization of record:
         if ($this->tsfe->sys_language_content) {
             // prevent link targets from being changed in localized records
             $tmpPage = $row['page'];
             $tmpExtURL = $row['ext_url'];
             $row = $this->tsfe->sys_page->getRecordOverlay('tt_news', $row, $this->tsfe->sys_language_content, $this->tsfe->sys_language_contentOL, '');
             $row['page'] = $tmpPage;
             $row['ext_url'] = $tmpExtURL;
         }
         // Register displayed news item globally:
         $GLOBALS['T3_VAR']['displayedNews'][] = $row['uid'];
         $this->tsfe->ATagParams = $pTmp . ' title="' . $this->local_cObj->stdWrap(trim(htmlspecialchars($row[$titleField])), $lConf['linkTitleField.']) . '"';
         if ($this->conf[$prefix_display . '.']['catOrderBy']) {
             $this->config['catOrderBy'] = $this->conf[$prefix_display . '.']['catOrderBy'];
         }
         //			if ($this->isRenderMarker('###NEWS_CATEGORY_ROOTLINE###')) {
         $this->categories = array();
         $this->categories[$row['uid']] = $this->getCategories($row['uid']);
         //			}
         $catSPid = FALSE;
         if ($row['type'] == 1 || $row['type'] == 2) {
             // News type article or external url
             $this->local_cObj->setCurrentVal($row['type'] == 1 ? $row['page'] : $row['ext_url']);
             $wrappedSubpartArray['###LINK_ITEM###'] = $this->local_cObj->typolinkWrap($this->conf['pageTypoLink.']);
             // fill the link string in a register to access it from TS
             $this->local_cObj->LOAD_REGISTER(array('newsMoreLink' => $this->local_cObj->typolink($this->pi_getLL('more'), $this->conf['pageTypoLink.'])), '');
         } else {
             //  Overwrite the singlePid from config-array with a singlePid given from the first entry in $this->categories
             if ($this->conf['useSPidFromCategory'] && is_array($this->categories)) {
                 $tmpcats = $this->categories;
                 if (is_array($tmpcats[$row['uid']])) {
                     $catSPid = array_shift($tmpcats[$row['uid']]);
                 }
             }
             $singlePid = $catSPid['single_pid'] ? $catSPid['single_pid'] : $this->config['singlePid'];
             $wrappedSubpartArray['###LINK_ITEM###'] = $this->getSingleViewLink($singlePid, $row, $piVarsArray);
//.........这里部分代码省略.........
开发者ID:mrmoree,项目名称:vkmh_typo3,代码行数:101,代码来源:class.tx_ttnews.php


注:本文中的TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::setCurrentVal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。