Project

General

Profile

Actions

Bug #29583

closed

TypoScript condition [userFunc]...[ELSE] does not work correctly

Added by Willi Martens about 13 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Documentation
Target version:
-
Start date:
2011-09-09
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.5
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

The following condition always includes both files:

[userFunc = user_match(userAgentIsMobile)]
<INCLUDE_TYPOSCRIPT: source="FILE: fileadmin/res/typoscript/setup/mobile_page.ts">
[else]
<INCLUDE_TYPOSCRIPT: source="FILE: fileadmin/res/typoscript/setup/page.ts">
[global]

The userfunc is defined in localconf.php

function user_match($cmd) {
  switch($cmd) 
  {
    case 'userAgentIsMobile':
      if(preg_match('/(IEMobile|like Mac OS X|Android|BlackBerry|Symbian|LG|NetFront|MIDP|Windows CE|NetFront|PlayStation|PLAYSTATION|MIDP|UP\.Browser|Nintendo)/', t3lib_div::getIndpEnv('HTTP_USER_AGENT'))){
        return TRUE;
      }
      break;
    default:
      return FALSE;
  }
  return FALSE;
}

Seems like the else-condition was ignored completely?

Actions #1

Updated by Chris topher about 13 years ago

  • Subject changed from else in typoscript condition to TypoScript condition [userFunc]...[ELSE] does not work correctly

As to what you describe it seems not only like the [ELSE] block is ignored, but that your complete condition is not recognized. If what you describe is true, also the first block seems to be treated as if it always returns TRUE.

Your example reminds me of the one we use in TSref to explain this condition and I never heard that this one is not working properly.

I think you will get help more quickly in the mailing lists. Ask at http://lists.typo3.org, maybe in the English list. There will be some people around, who can help you.

Actions #2

Updated by Willi Martens about 13 years ago

Hello Christopher thank you for the link.

Yes i've seen the condition example at the TSref. The condition works and the first block is treated only if the HTTP_USER_AGENT matches as it should. Only the ELSE-Block is treated always. I mean, in the case that the HTTP_USER_AGENT not match is it correct that the else block is treated. But the ELSE-Block is treated also as the HTTP_USER_AGENT matches.

Kind regards,
Willi

Actions #3

Updated by Willi Martens about 13 years ago

Ok, it is a little confusing. After a couple more tests I found out the following behavior. The condition is ok as long as you don't use "INCLUDE_TYPOSCRIPT". As soon as you use includes in the condition the includes are done independently of the condition!

Actions #4

Updated by Philipp Gampe about 11 years ago

  • Status changed from New to Needs Feedback
  • Is Regression set to No

Yes, includes are processed before any other TS parsing.

You should use the TypoScript Analyzer to find out if the condition matches correctly (hint: you change check and uncheck conditions there).

Actions #5

Updated by Alexander Opitz almost 11 years ago

  • Category changed from TypoScript to Documentation

Do you use it in the setup or in the constants part?

Actions #6

Updated by Alexander Opitz over 10 years ago

  • Status changed from Needs Feedback to Closed

No feedback within the last 90 days => closing this ticket.

If you think that this is the wrong decision or experience this issue again, then please write to the mailing list typo3.teams.bugs with issue number and an explanation or open a new ticket and add a relation to this ticket number.

Actions #7

Updated by Oliver Weiss about 10 years ago

This issue is still open.

Conditions are not working for Typoscript Includes.

Obviously it's not possible to solve this problem. It must be mentioned in the documentation then.

Actions

Also available in: Atom PDF