如何在 TYPO3 7.6 中启用 header_position [英] How to enable header_position in TYPO3 7.6

查看:28
本文介绍了如何在 TYPO3 7.6 中启用 header_position的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 TYPO3 7.6 之前的版本中,您可以为内容元素中的标题选择一个位置(我记得是左、中、右).

In versions prior to TYPO3 7.6 you could select a position for your header within your content element (left, middle, right as far as I remember).

用于在 tt_content header_position 中存储该信息的字段仍然可用.

The field which has been used for storing that information in tt_content header_position is still available.

但是,它不会出现在后端.我还使用 fluid_styled_content 来呈现我的内容,并且 Header 部分不包含对位置的任何引用,而只包含对布局字段的引用.

However, it will not appear in the backend. I'm also using fluid_styled_content for rendering my content, and the Header partial doesn't contain any reference to the position, but only to the layout field.

我的问题是:如何重新启用该字段并使用它来定位我的标题?

My question is: How can I reenable that field and use it to position my headers?

推荐答案

您必须快速构建一个可以重新启用该领域的扩展.您需要创建文件夹和文件,如下所示:your_ext/Configuration/TCA/Overrides/tt_content.php该文件的内容是:

You have to build a quick extension of yours which can reenable the field. You need to create folders and a file like following: your_ext/Configuration/TCA/Overrides/tt_content.php the contents of that file are:

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
ExtensionManagementUtility::addTCAcolumns('tt_content',[
    'header_position' => [
            'exclude' => 1,
            'label' => 'LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:tt_content.header_position',
            'config' => [
                    'type' => 'select',
                    'renderType' => 'selectSingle',
                    'items' => [
                            ['LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:tt_content.header_position.left', 'left'],
                            ['LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:tt_content.header_position.right', 'right'],
                            ['LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:tt_content.header_position.center', 'center']
                    ]
            ]
    ]   
]);

ExtensionManagementUtility::addFieldsToPalette('tt_content', 'header', '--linebreak--,header_position', 'after:header_layout');

ExtensionManagementUtility::addFieldsToPalette('tt_content', 'headers', '--linebreak--,header_position', 'after:header_layout');

现在该字段应该回到后端,因为您已经通过 addTCAColumns 将它添加到 TCA 到 tt_content 配置并通过 addFieldsToPalette 添加它tt_contentheaderheaders 调色板,由 textmedia 和 <强>标题.您可以通过使用 TYPO3 后端中的配置模块来了解更多信息.当您以管理员身份登录时,您可以看到它.另一个查看和了解 TCA 的好地方是 TCA 参考:https://docs.typo3.org/typo3cms/TCAReference/

Now the field should be back in the backend, because you've added it to the TCA via addTCAColumns to the tt_content configuration and added it via addFieldsToPalette to the header and headers palettes of tt_content, which are used by the types textmedia and header. You can find out more about this by using the Configuration module in the TYPO3 backend. You can see it, when you are logged in as admin. Also a good place to look and learn about the TCA is the TCA reference: https://docs.typo3.org/typo3cms/TCAReference/

现在您需要更改fluid_styled_content 模板.您需要为 fluid_styled_content 的标题部分创建模板覆盖.

Now you need to alter the fluid_styled_content templates. You need to create template overrides for the header partial of fluid_styled_content.

首先创建一个文件夹:your_ext/Configuration/TypoScript 并添加一个 setup.txt 和一个 constants.txt 文件.在 setup.txt 中添加以下几行:

First create a folder: your_ext/Configuration/TypoScript and add a setup.txt and a constants.txt file. In setup.txt add the following lines:

lib.fluidContent{
    templateRootPaths{
         10 = {$plugin.your_ext.view.fluid_styled_content.templateRootPath}
    }
    partialRootPaths{
         10 = {$plugin.your_ext.view.fluid_styled_content.partialRootPath}
    }
    layoutRootPaths{
        10 = {$plugin.your_ext.view.fluid_styled_content.layoutRootPath}
    }
}

constants.txt 中:

plugin.your_ext{
    view{
        fluid_styled_content{
            templateRootPath = EXT:your_ext/Resources/Private/FluidStyledContent/Templates/
            partialRootPath = EXT:your_ext/Resources/Private/FluidStyledContent/Partials/
            layoutRootPath = EXT:your_ext/Resources/Private/FluidStyledContent/Layouts/
        }
    }
}

要启用您的 TypoScript,您需要在 your_ext 文件夹中添加一个 ext_tables.php 并为其添加以下一行代码:

To enable your TypoScript, you need to add a ext_tables.php in your your_ext folder and give it the following one-liner:

TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY,'Configuration/TypoScript', 'Your Ext Template');

您需要通过模板模块将静态 TypoScript 包含到您的页面中,以启用对 fluid_styled_content

You need to include your static TypoScript to your page via the Template module to enable the change to fluid_styled_content

现在您可以从

typo3/sysext/fluid_styled_content/Resources/Private/Templates

typo3/sysext/fluid_styled_content/Resources/Private/Partials

typo3/sysext/fluid_styled_content/Resources/Private/Layouts

进入您需要创建的扩展文件夹:

into your extensions folders you need to create:

your_ext/Resources/Private/FluidStyledContent/Templates

your_ext/Resources/Private/FluidStyledContent/Partials

your_ext/Resources/Private/FluidStyledContent/Layouts

现在您可以更改模板.对于您的 header_position 字段,您可能只需要复制

Now you can alter the templates. For your header_position field, you probably just need to copy

typo3/sysext/fluid_styled_content/Resources/Private/Partials/Heaeder.html

your_ext/Resources/Private/FluidStyledContent/Partials/Header.html

并将您选择的值作为 {data.header_position} 添加到 div 类和样式.

and add your selected value as {data.header_position} to a div class and style that.

请记住,您不需要复制所有模板,因为使用 TypoScript,您只是为 fluid 定义了另一个位置来搜索模板并获取它们(如果它们可用).如果不是,fluid 将返回链并获取在位置 9 及更低位置定义的模板.您可以通过模板模块查看 TypoScript 对象浏览器,并查看 TypoScript 变量 lib.FluidContent 以查看您的 TypoScript 包含是否有效.

Keep in mind you do not need to copy all of the templates, because with the TypoScript you just defined another location for fluid to search for templates and take them, if they are available. If not, fluid will walk back the chain and take the templates that are defined at position 9 and lower. You can look into the TypoScript Object Browser by the Template module and look into the TypoScript variable lib.FluidContent to see, if your TypoScript include has worked.

希望这有点帮助;)

这篇关于如何在 TYPO3 7.6 中启用 header_position的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆