简体   繁体   English

在Typo3 Fluid模板内创建ViewHelpers

[英]Creating ViewHelpers inside Typo3 fluid template

I want to build a Typo3 template from scratch using Fluid. 我想使用Fluid从头开始构建Typo3模板。 I'm new to this CMS, but have knowledge in Zend Framework which uses a similar MVC approach. 我是这个CMS的新手,但是对使用类似MVC方法的Zend Framework有所了解。 What I don't know is where to put the ViewHelpers inside my template. 我不知道将ViewHelpers放在模板中的什么位置。

I have the following directory structure: 我有以下目录结构:

typo3/fileadmin/
    projectname/
        templates/
            assets/
                images
                js
                styles/
                    css/
                    less/
            layouts/
                single.html
                2col.html
                3col.html
            partials/
                breadcrumb.html
            default.html
        tsconfig/
        typoscript/
            constants.ts
            setup.ts  

All I found on the web were tutorials using Fluid inside a Typo3 extension. 我在网上发现的所有内容都是在Typo3扩展程序中使用Fluid的教程。 I'd like to register a new namespace for my classes, define a directory for the autoloader and use the viewhelpers inside my templates and not inside an extension (eg <my:formatMyWay> ) 我想为我的类注册一个新的名称空间,为自动加载器定义一个目录,并在模板内而不是扩展内使用viewhelpers(例如<my:formatMyWay>

Is there something similar inside the templates? 模板内部是否有类似内容? Or do I have to create my own Typo3 extension for this? 还是我必须为此创建自己的Typo3扩展?

You're right, you have to create your own TYPO3 extension in order to have own viewhelpers. 没错,您必须创建自己的TYPO3扩展名才能拥有自己的viewhelper。 You can use the extension_builder to kickstart an empty extension. 您可以使用extension_builder来启动一个空扩展名。 Then add your viewhelper under typo3conf/ext/my_ext/Classes/ViewHelpers/ and add this namespace to the top of your template: {namespace my=Tx_MyExt_ViewHelpers} . 然后在typo3conf/ext/my_ext/Classes/ViewHelpers/添加typo3conf/ext/my_ext/Classes/ViewHelpers/ ,并将此命名空间添加到模板顶部: {namespace my=Tx_MyExt_ViewHelpers} This simple guide may also help you to create the viewhelper itself. 这个简单的指南还可以帮助您创建viewhelper本身。 An advantage is that you can nicely package the viewhelpers and use them in multiple projects. 优点是您可以很好地打包viewhelper并将其用于多个项目中。

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

相关问题 如何在流体模板中使用自定义Viewhelpers? - How to use custom Viewhelpers inside a fluid template? TYPO3 Fluid - 模板分页 - TYPO3 Fluid - Template Paginate Typo3:禁用gridelements流体模板内viewhelper的缓存 - Typo3: Disable caching for viewhelper inside gridelements fluid template TYPO3 DCE 在流体模板文件中使用大括号 - TYPO3 DCE use curly bracket inside fluid template file TYPO3流体中的f:link和f:uri ViewHelpers有什么区别 - What is the difference between f:link and f:uri ViewHelpers in TYPO3 fluid #1237900529:参数“每个”已注册为“数组”类型,但在视图助手“ TYPO3 \\ CMS \\ Fluid \\ ViewHelpers \\ ForViewHelper”中为“ string”类型 - #1237900529: The argument “each” was registered with type “array”, but is of type “string” in view helper “TYPO3\CMS\Fluid\ViewHelpers\ForViewHelper” 如何使用TYPO3 Fluid ViewHelpers和strftime格式化简短的德语天名称? - How to format short german day names with TYPO3 fluid viewhelpers and strftime? TYPO3 Fluid在动态渲染模板中的使用 - TYPO3 Fluid usage in dynamically rendered template typo3:带有错字的流体模板中的社交图标 - typo3: social icons in fluid template with typoscript 带有可变模板(typo3)的html5网站 - html5 website with fluid template (typo3)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM