Use of Fluid templates

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Dennis
Posts: 15
Joined: 30 Nov 2016, 09:16

Use of Fluid templates

Post by Dennis » 22 Mar 2017, 16:41

Hello!

On https://aimeos.org/docs/TYPO3/Use_Fluid_templates you describe
Since version 2017.04, you can alternatively use the TYPO3 Fluid template engine for Aimeos templates overwritten for your project. Thus, all your templates will be in the same template language.

...

The Fluid view helpers available by default can't give you access to all data you need. Therefore, the Aimeos package contains some view helpers to retrieve data from Aimeos specific sources like configuration settings or translations. You have to include this view helpers by adding this to the Fluid template before using them:

...
I followed your instructions on the given site and the new fluidtemplate was successfully loaded. But I cannot achieve to access the catalog or product data I need in the templates and give this data out, for example.

My questions are now:

1) How precisely do you access the data you need? Which view helper should I use to get contents like $this->get( 'detailBody' ) ? How can short php blocks before <?php $this->block()->start( ' ... ' ); ?> be realized?

For example, how would you transform a standard Aimeos template like catalog/detail/body-default.php to a fluidtemplate. Could you make it a bit more clear, please?

2) Do some fluidtemplates for catalog list or detail views already exists?

3) What is the current state of development concerning this topic?

Many thanks in advance!

TYPO3 7.6.15, Aimeos web shop 17.3.0, PHP version 5.6.30-0+deb8u1, Linux

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Use of Fluid templates

Post by aimeos » 22 Mar 2017, 17:04

Dennis wrote: 1) How precisely do you access the data you need? Which view helper should I use to get contents like $this->get( 'detailBody' ) ? How can short php blocks before <?php $this->block()->start( ' ... ' ); ?> be realized?
That's described in the docs: https://aimeos.org/docs/TYPO3/Use_Fluid ... tes#Blocks
All data that is retrieved via "$this->get()" or "$this->varname" and "$this->get('detailBody')" is available as "{detailBody}"
Dennis wrote: For example, how would you transform a standard Aimeos template like catalog/detail/body-default.php to a fluidtemplate. Could you make it a bit more clear, please?
That's one of the most complex templates. Fluid is still very restrictive and prevent you from working with the objects in a convenient way. There's a discussion about this in the Fluid repository: https://github.com/TYPO3/Fluid/issues/277

Up to now, it seems you will need a lot of view helpers to retrieve and transform the data according to your needs ...
Dennis wrote: 2) Do some fluidtemplates for catalog list or detail views already exists?
No, not that we know.
Dennis wrote: 3) What is the current state of development concerning this topic?
It's still experimental. We need people who want to use Fluid for the Aimeos templates and are willing to see what's possible and where the problems are. And to convince the Fluid guys to allow more complex things than just {detailProductItem.name} :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

gilbertsoft
Posts: 28
Joined: 18 Nov 2016, 10:35

Re: Use of Fluid templates

Post by gilbertsoft » 27 Mar 2017, 18:27

Last week I thought about using Fluid templates. Today I have found this interesting post and like to add my 5 cents:
  • How much will the rendering time be affected? But since there are no known templates there wont be an answer for now?
  • Would it be faster enabling the CMS's caching? All Aimeos controller actions are declared non caching as I know.
  • What are the plans with Fluid? Will you use it in other distros too? Complete switch from the current html client or just offering an other templating engine?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Use of Fluid templates

Post by aimeos » 28 Mar 2017, 20:29

The Fluid template engine has an integrated cache, so there is probably a performance loss compared to PHP templates but that might be not that big. We would be interested in figures too :-)

The Aimeos output is non-cacheable because it manages it's own cache and handles non-cacheable parts itself. It doesn't benefit from TYPO3 caching.

Fluid is only an option for TYPO3 and Flow/NeosCMS. In Laravel the Blade template engine is supported instead while in Symfony it's Twig. The default template engine will always be the PHP engine because it's the fastest one available and is the only one that is available in all applications and frameworks.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

gilbertsoft
Posts: 28
Joined: 18 Nov 2016, 10:35

Re: Use of Fluid templates

Post by gilbertsoft » 29 Mar 2017, 08:07

Thanks for the explanations!

Perhaps someone finds the time to figure this out...

Yes, that's clear. But I didn't know Fluid has it's own caching, I thought it uses TYPO3 cache.

Because Fluid is independant, it should be possible to use it everywhere, isn't it?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Use of Fluid templates

Post by aimeos » 30 Mar 2017, 08:34

The Fluid cache isn't a content cache like managed by the TYPO3 caching framework. It's the result of the transformation of the Fluid templates into PHP for faster execution.

Yes, in theory it's possible to use it in every PHP application but it's not used outside of the TYPO3 and Flow/NeosCMS world yet.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

yacms
Posts: 16
Joined: 07 Jun 2018, 13:31

Re: Use of Fluid templates

Post by yacms » 14 Sep 2018, 11:30

Hello,
i hope its okay to revive this old thread.

I am currently working on a book-shop and have an page listed with all autors which have the product ID of their written books "mapped"

I want to show the product title (Book name in my case) by product ID. How can i achieve this in my FLUID Template?

"{buch.bookID}" contains the product ID.

Code: Select all

{namespace dce=ArminVieweg\Dce\ViewHelpers}
{namespace v=FluidTYPO3\Vhs\ViewHelpers}
{namespace ai=Aimeos\Aimeos\ViewHelper}
<div class="dce">
	<div class="row no-padding">
		<div class="col-md-12 no-padding autor" data-name="{field.lastname}" data-uid="">
			<v:media.exists file="uploads/autoren/{field.picture}">
				<f:then>
					<div class="col-md-3 no-padding"><f:image src="/uploads/autoren/{field.picture}" width="180" alt="{field.surname} {field.lastname}" /></div>
					<div class="col-md-9">
						<span class="name">{field.surname} </span>
						<span class="nachname">{field.lastname}</span>
						<br/><br/>
						<f:format.crop maxCharacters="200">
							<f:format.html>{field.biography}</f:format.html>
						</f:format.crop>
						<br/>
						<f:for each="{field.publishedBooks}" as="buch">
							{buch.bookID}<br />
						</f:for>
						<br/>
						<f:link.page additionalParams="{detailDceUid:contentObject.uid}">Mehr</f:link.page>
					</div>
				</f:then>
				<f:else>
					<div class="col-md-12 no-padding">
						<span class="name">{field.surname} </span>
						<span class="nachname">{field.lastname}</span>
						<br/><br/>
						<f:format.crop maxCharacters="200">
							<f:format.html>{field.biography}</f:format.html>
						</f:format.crop>
						<br/>
						<f:for each="{field.publishedBooks}" as="buch">
							{buch.bookID}<br />
						</f:for>
						<br/>
						<f:link.page additionalParams="{detailDceUid:contentObject.uid}">Mehr</f:link.page>
					</div>
				</f:else>
			</v:media.exists>
		</div>
	</div>
</div>

Post Reply