Project

General

Profile

Actions

Bug #71031

closed

Fluid if-viewhelper excutes else code if inline syntax?

Added by Henri Nathanson about 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2015-10-26
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.5
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

The problem I had today was with this view helper inline notation. The banner is not set. The value for bannerImage is empty string ''. The rendering runs into an file reference not found error. What comes by the uri.image() call. Problem is, the invalid 'then' blocks code is executed.

style="{f:if(condition:settings.display.bannerImage,
           then:'background-image: url({f:uri.image(src: settings.display.bannerImage, treatIdAsReference:1, height:700px)})'
       )}" 

This fixes it:
style="<f:if condition="{settings.display.bannerImage}">background-image: url(<f:uri.image src="{settings.display.bannerImage}" treatIdAsReference="1" height="700" />)</f:if>

Maybe I am missing something here? Could it really be the inline notation is less reliable here? Thx for comments.

Actions #1

Updated by Henri Nathanson about 9 years ago

This is with version 7.5

Actions #2

Updated by Claus Due about 9 years ago

  • Status changed from New to Closed
  • String-nested call to f:uri.image uses invalid syntax (unresolvable variable references)
  • Height dimensions not quoted string, likely to cause bad parsing
  • Quotes are not correctly nested, sure to cause bad parsing

Please try:

style="{f:if(condition: settings.display.bannerImage,
           then: 'background-image: url(
               {f:uri.image(src: \'{settings.display.bannerImage}\', treatIdAsReference: 1, height: \'700px\')}
           )'
       )}" 

Which should work.

Closing this since no, there isn't an error in using inline syntax for f:if - but I agree that inline syntax can be very hard to handle if you don't know all the internals about how a string gets parsed for the presence of inline ViewHelper calls.

Actions #3

Updated by Henri Nathanson about 9 years ago

I don't get it running with your syntax. It still throws the same error.

The right inline syntax whould support the encapsulated f:uri.image helper is not parsed. But then, it would need to be parsed later on, while the blocks or the if statement are being executed. Some form of late bind parsing? I have no clue. But I guess, that is not the case. No late parsing.

So at the end I stay with a feeling the inline notation is not really realiable here and will generally try to avoid it.

Actions

Also available in: Atom PDF