1
votes

I am facing issue in tyopscript to check the true false condition for the temp.info variable. From below function I am getting 0 or 1 from the function -

temp.info = USER_INT
temp.info {
    userFunc = tx_gowebsso_pi1->excludeMenu
    includeLibs = EXT:gowebsso/pi1/class.tx_gowebsso_pi1.php
}

I am printing this value and getting correct

but when I try to check it like

[temp.info = 1]

or

[temp.info = 0]

It's not going into the conditions. I tried all the ways. Please help me how I can set conditions in typoscript.

1

1 Answers

0
votes

You could use this condition: [userFunc = yourFuncName(argument)]

But you have to edit your configuration-file to register your function. Please read more about userFunc and conditions in the manual.

Another way to check if an userFunc returns true or false and print different content on each state:

Using a php-file located in fileadmin/php/myUserfunc.php. checkSomeThing() returns a value. In this case it is 1.

<?php
    class user_myFuncs {
        function checkSomeThing ($content, $conf){
            $content = 1;
            return $content;
        }
    }
?>

You can print different contents on true and false like this:

page >
includeLibs.truefalse = fileadmin/php/myUserfunc.php
page = PAGE
page {
  10 = TEXT
  10 {
    value = Show this, if checkSomeThing () returns something which is true

    if.isTrue.postUserFunc = user_myFuncs->checkSomeThing
  }

  20 = TEXT
  20 {
    value = Show this, if checkSomeThing () returns something which is false

    if.isTrue.postUserFunc = user_myFuncs->checkSomeThing
    if.negate = 1
  }
}