[TYPO3-english] Re: Best practice with namespaces? Flux, VHS, etc.

Viktor Livakivskyi invisible.kinder at gmail.com
Mon Oct 20 13:15:22 CEST 2014


Hi, Jennifer


> I have a question about best practices for using namespaces in HTML templates using fluid, flux, vhs, etc. I see two different ways of doing this:
> 
> {namespace v=Tx_Vhs_ViewHelpers}
> 
> or 
> 
> <div xmlns="http://www.w3.org/1999/xhtml"
> xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers">

Both are right, but I prefer second variant, because it is more correct from XML structure view and it allows your IDE to highlight and auto-complete custom tags. Im my case I have PhpStorm and I just need to define correct schemas in "Schemas and DTDs" section of settings (e.g.  URI "http://typo3.org/ns/fluid/ViewHelpers" is linked to this file: https://fluidtypo3.org/schemas/fluid-master.xsd) and then I can benefit of IDE features.


> Which is preferable? Is it enough to include the namespace on the Index.html template, or does this need to be included on templates that are included as content elements via a plugin? What about on partials?

It is needed in all your files, that use custom tags. The only problem may be with layouts, since you cna't wrap layout in a div-tag with namespaces definition, becasue it will be output on a page, so here I'm still using {namespace} definition, but in all the templates and partials I have sections and onle sections are rendered, so I can wrap the complete template in div-tag with schemas definitions.


> but there are so many holes, things not explained that are imo not obvious. For example what needs to be in the Layout/Content.html for the following template construction:
> 
> <div xmlns="http://www.w3.org/1999/xhtml" lang="en"
>       xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"
>       xmlns:flux="http://typo3.org/ns/FluidTYPO3/Flux/ViewHelpers"
>       xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers">
> 
> <f:layout name="Content" />
> 
> <f:section name="Configuration" />
> 
> <f:section name="Preview" />
> 
> <f:section name="Main" />
> 
> </div>
> 
> Does Content.html need to render "Configuration" and "Preview" as well as "Main"? Whatever I try, I can't get my flux forms under "Configuration" to show up in some tab in the backend when editing that page, although the frontend-part shows up fine.
> 
> Is there something online yet that can provide more detail about how to work with these extensions correctly?

Content.html is a template, which uses layout Content. So, it is up to layout, what section to render. In case of Flux, "Configuration" is about BE forms view, "Preview" - is about BE preview in Page module, "Main" is about FE output.
You can have any other sections in your template and render them in layout or even in same template - depends on templates structure, you've developed.
You can read more about Fluid here: http://typo3buddy.com/typo3-template-tutorial/fluid/


More information about the TYPO3-english mailing list