简体   繁体   English

如何控制TYPO3的Twitter Bootstrap程序包中Carousel元素的速度

[英]How can I control the speed of the Carousel element in the Twitter Bootstrap Package in TYPO3

I have tried to find an answer, but all I get is answers on how to control the speed when implementing Twitter Bootstrap by your self. 我试图找到一个答案,但我得到的只是关于如何自行实现Twitter Bootstrap时如何控制速度的答案。

I cannot figure out how to do it in TYPO3. 我无法弄清楚如何在TYPO3中做到这一点。 I think it should be done through TypoScript, but how? 我认为应该通过TypoScript完成,但是如何?

In Bootstrap 3's Carousel, you can set the option interval or data-interval , see http://getbootstrap.com/javascript/#carousel . 在Bootstrap 3的Carousel中,您可以设置选项intervaldata-interval ,请参见http://getbootstrap.com/javascript/#carousel

You know that already. 你已经知道了 Here's how I'd do it: 这是我的处理方式:

First you have to find out if the extension can set that parameter at all. 首先,您必须找出扩展程序是否可以完全设置该参数。 Supposing the manual is quiet on that, you want to check the Constant Editor under Templates > Constant Editor first. 假设该手册尚不完善,您首先要在“模板”>“常量编辑器”下检查“常量编辑器”。 No luck yet. 还没有运气。

So you will have to look at the code of typo3conf/ext/bootstrap_package . 因此,您将不得不查看typo3conf/ext/bootstrap_package的代码。 Everything that can be set via TypoScript will probably be in /Configuration/TypoScript/ : constants.txt and/or setup.txt . 可以通过TypoScript设置的所有内容都可能在/Configuration/TypoScript/constants.txt和/或setup.txt Nothing there for the carousel, though. 旋转木马什么也没有。

Now the I would search for interval in the entire extension, using your favourite editor. 现在,我将使用您喜欢的编辑器在整个扩展中搜索interval Ah, there you are: In the file /Resources/Private/Templates/ContentElements/Bootstrap/Carousel.html you will find the interval of 10seconds hardcoded: 啊,您来了:在文件/Resources/Private/Templates/ContentElements/Bootstrap/Carousel.html您会发现10秒的间隔是硬编码的:

<div id="carousel-{data.uid}" class="carousel slide{f:if(condition: '{data.layout} == 110',then:' carousel-small')}" data-interval="10000" data-ride="carousel">

Of course, do NOT edit the extension as you have to keep it updateable. 当然,不要编辑扩展名,因为必须保持其可更新。 No problem, though. 没问题。

If you search for Carousel.html , you will find it in /Configuration/ContentElements/Bootstrap/Carousel.ts : 如果搜索Carousel.html ,则会在/Configuration/ContentElements/Bootstrap/Carousel.ts找到它:

tt_content.bootstrap_package_carousel = COA
tt_content.bootstrap_package_carousel {
    10 =< lib.stdheader
    20 = FLUIDTEMPLATE
    20 {
        file = {$plugin.bootstrap_package_contentelements.view.templateRootPath}Bootstrap/Carousel.html
        partialRootPath = {$plugin.bootstrap_package_contentelements.view.partialRootPath}
        layoutRootPath = {$plugin.bootstrap_package_contentelements.view.layoutRootPath}
    }
}

So that's where the path to the template is set. 这就是设置模板路径的地方。 And oho! 哦! The thing inside the curly brackets is a constant. 大括号内的东西是一个常数。 Turns out that right at the beginning, we could have set a complete new path to include a copy of all bootstrap templates from bootstrap_package/Resources/Private/Templates/Page/ and do the modification there. 事实证明,一开始,我们可以设置一条完整的新路径,以包含bootstrap_package/Resources/Private/Templates/Page/中所有引导模板的副本,并在那里进行修改。 As well as for Partials and Layouts, which are other, larger and smaller chunks of fluid templates (cf. http://typo3.org/documentation/article/the-fluidtemplate-cobject/ ). 以及Partials和Layouts,它们是流体模板的其他更大或更小的块(请参见http://typo3.org/documentation/article/the-fluidtemplate-cobject/ )。

If out of some reason you'd only like to modify that very specific part of the bootstrap package, you can set something like this in your TypoScript: 如果出于某种原因您只想修改bootstrap软件包中非常特定的部分,则可以在TypoScript中进行如下设置:

tt_content.bootstrap_package_carousel.20.file = /path/to/my/template/ext/Bootstrap/Carousel.html

Now all you have to do is to create a copy of the carousel template and edit it at will - in the rendering process, your own template will be used, featuring faster intervals. 现在,您要做的就是创建轮播模板的副本并随意进行编辑-在渲染过程中,将使用您自己的模板,间隔时间更快。

This should also demonstrate the overriding powers of TypoScript nicely - you can do stuff like that at any point in the page tree for the branch you want. 这也应该很好地展示TypoScript的强大功能-您可以在页面树中的任意位置为所需分支做类似的事情。

Also, I'd like to point out that I find this a very good approach to the authoring of TYPO3 extensions: instead of having dozens and dozens of constants that could be set in the backend like in the old days, we now have replaceable fluid templates with clear structure. 另外,我想指出的是,我发现这是编写TYPO3扩展的一种非常好的方法:与其像过去一样,可以在后端设置数十个常量,我们现在可以更换流体具有清晰结构的模板。 Much more maintainable and easier to use this way! 这种方式更容易维护和使用!

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

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