Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/147.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TYPO3从扩展设置流体页面对象的标题_Typo3_Typoscript_Fluid_Extbase_Fluid Layout - Fatal编程技术网

TYPO3从扩展设置流体页面对象的标题

TYPO3从扩展设置流体页面对象的标题,typo3,typoscript,fluid,extbase,fluid-layout,Typo3,Typoscript,Fluid,Extbase,Fluid Layout,我想在扩展中设置页面标题,因此流体模板中的当前{page}对象也将显示设置的标题 $GLOBALS['TSFE']->altPageTitle=$pageTitle只设置标记,对{page.title}没有影响 我的主要目标是:在面包屑中显示细节页面的“正确”标题 你知道如何操作吗?对于缓存页面和插件,这应该可以: $GLOBALS['TSFE']->page['title'] = $pageTitle; 我对流体中的{page}对象一无所知,所以我使用了一个类似于 /** *用于在标记

我想在扩展中设置页面标题,因此流体模板中的当前{page}对象也将显示设置的标题

$GLOBALS['TSFE']->altPageTitle=$pageTitle
只设置
标记,对{page.title}没有影响

我的主要目标是:在面包屑中显示细节页面的“正确”标题


你知道如何操作吗?

对于缓存页面和插件,这应该可以:

$GLOBALS['TSFE']->page['title'] = $pageTitle;

我对流体中的{page}对象一无所知,所以我使用了一个类似于

/**
*用于在标记中设置文档标题的视图帮助器。
*
*=示例=
*
*{blog.name}
* 
*这里有东西
* 
*头衔
* 
*@许可证http://www.gnu.org/licenses/lgpl.html GNU Lesser通用公共许可证,第3版或更高版本
*/
类PageTitleViewHelper扩展\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper{
/**
*@var bool
*/
受保护的$escapeOutput=false;
/**
*@param string$mode方法,用于将新标题添加到现有标题。
*@param string$glue使用此字符串将新标题粘贴到旧标题。
*@param string$display如果呈现,此标记将显示其子项。默认情况下,它不显示任何内容。
*@返回字符串呈现内容或空白,具体取决于显示模式。
*@作者Nathan Lenz
*/
公共函数呈现($mode='replace',$glue='-',$display='none'){
$renderContent=$this->renderChildren();
$existingTitle=$GLOBALS['TSFE']->页面['title'];
如果($mode=='prepend'&&&!empty($existingTitle)){
$newTitle=$renderedContent.$glue.$existingTitle;
}如果($mode==='append'&&&!empty($existingTitle))则为else{
$newTitle=$existingTitle.$glue.$renderedContent;
}否则{
$newTitle=$renderedContent;
}
$GLOBALS['TSFE']->page['title']=$newTitle;
$GLOBALS['TSFE']->IndexedActitle=$newTitle;
如果($display==='render'){
返回$rendercontent;
}否则{
返回“”;
}
}
}

遗憾的是,没有。这只设置页面标题,而不是页面对象中的标题。您的页面和插件被缓存?没有,所有缓存也被清除。需要明确的是,如果这样做,页面对象中的title属性会改变吗?不仅仅是html标记?同样,它不是关于在html中设置标记-这是有效的,它将覆盖页面对象中的标题(执行{u all}/{page}并看到当前页面对象)
/**
 * A view helper for setting the document title in the <title> tag.
 *
 * = Examples =
 *
 * <page.title mode="prepend" glue=" - ">{blog.name}</page.title>
 * 
 * <page.title mode="replace">Something here</page.title>
 * 
 * <h1><page.title mode="append" glue=" | " display="render">Title</page.title></h1>
 * 
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
 */
class PageTitleViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {

  /**
   * @var bool
   */
  protected $escapeOutput = false;

    /**
     * @param string $mode Method for adding the new title to the existing one.
     * @param string $glue Glue the new title to the old title with this string.
     * @param string $display If render, this tag displays it's children. By default it doesn't display anything.
     * @return string Rendered content or blank depending on display mode.
     * @author Nathan Lenz <nathan.lenz@organicvalley.coop>
     */
    public function render($mode = 'replace', $glue = ' - ', $display = 'none') {

        $renderedContent = $this->renderChildren();

        $existingTitle = $GLOBALS['TSFE']->page['title'];

        if ($mode === 'prepend' && !empty($existingTitle)) {
            $newTitle = $renderedContent.$glue.$existingTitle;
        } else if ($mode === 'append' && !empty($existingTitle)) {
            $newTitle = $existingTitle.$glue.$renderedContent;
        } else {
            $newTitle = $renderedContent;
        }

        $GLOBALS['TSFE']->page['title'] = $newTitle;
        $GLOBALS['TSFE']->indexedDocTitle = $newTitle;


        if ($display === 'render') {
            return $renderedContent;
        } else {
            return '';
        }
    }
}