简体   繁体   English

TYPO3模板覆盖

[英]TYPO3 template override

All, 所有,

I am working on a simple and straightforward site with TYPO3 CMS. 我正在使用TYPO3 CMS在一个简单直接的网站上工作。 Using a template, all of the pages have the same banner image displayed at the top of the page. 使用模板,所有页面在页面顶部显示相同的标题图像。 I want to change this image on one of the pages to a different image. 我想将其中一页上的图像更改为其他图像。 What is the best way to go about this? 最好的方法是什么?

The image is being loaded from a template extension called 'Banner' which looks like this: 正在从名为“横幅”的模板扩展加载图像,如下所示:

temp.banner = COBJ_ARRAY
temp.banner {
# Menu 1 cObject
20 = IMAGE
20.file.import = upload/pics
20.file = fileadmin/template/main/template_1_FILES/{$banner_img}
}

I then tried to make a template extension on the one page which looked like this: 然后,我尝试在一页上进行模板扩展,如下所示:

temp.banner {
20.file = fileadmin/template/main/template_1_FILES/otherimage.jpg
]

But this did not change the image. 但这并没有改变图像。 The original image was still displayed without any errors or sign that the extension did anything. 原始图像仍然显示,没有任何错误,也没有迹象表明扩展程序已执行任何操作。

You are using a constant {$banner_img} so just change that value in the template on the page where it should be changed. 您使用的是常量{$banner_img}因此只需在页面上的模板中更改该值即可更改它。

I guess, if you rename your Object from temp.banner to lib.banner it will work like you expect. 我猜想,如果将Object从temp.banner重命名为lib.banner ,它将按预期运行。 The reason is, that the name "temp" is really temporary. 原因是名称“ temp”实际上是临时的。 It will be removed from cached TypoScript Templates. 它将从缓存的TypoScript模板中删除。 So just avoid that name, if you do not really understand what happens. 因此,如果您不太了解会发生什么,请避免使用该名称。

What i mean: 我的意思是:

temp.test = Hello World
page.10 = TEXT
page.10.value < temp.test

That would output "Hello World" like expected. 这将输出预期的“ Hello World”。 But temp.test is not available in other templates. 但是temp.test在其他模板中不可用。

The problem is that your changed the temp.banner. 问题是您更改了temp.banner. after it has been copied to another place. 复制到另一个地方后。 The TS from an extension template comes after all the TS from the original template has been parsed. 扩展模板中的TS解析完原始模板中的所有TS之后。

You must change either the constent via the content editor (see top select) or you have to change the exact place where the temp.banner. 您必须通过content editor更改常量(请参见顶部选择),或者必须更改temp.banner.的确切位置temp.banner. is copied to. 复制到。 You can use the TS object browser (see top select again) to find and change that place directly. 您可以使用TS object browser (再次参见顶部选择)直接查找和更改该位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM