Has anyone managed to do this? The main help says it's possible (see the bottom of the Using PHP topic. Actinic says no with a nice big crash dump whenever I try it, even with the simplest of PHP code.
Announcement
Collapse
No announcement yet.
Successfully using PHP in a condition
Collapse
X
-
Why not show your code and see if anyone can spot a mistake.
Mike-----------------------------------------
First Tackle - Fly Fishing and Game Angling
-----------------------------------------
-
It was more of a general question really. My though process:- The example in the help doesn't work.
- There's no UI in the condition editor to create the blocks as detailed by the help.
- Quick survey reveals nobody is using the feature.
== probably broken in V9 == don't waste any more time pursuing the problem.
Anyway, it's the code at the bottom of the help topic I mentioned, being pasted into Standard Layout Using CSS. Even doing something as innocuous asCode:<actinic:block php="true">1==1</actinic:block>
Code:<actinic:block php="true" selectable="false">1</actinic:block>=1
Code:<actinic:block php="true" selectable="false">1==1</actinic:block>
Comment
-
Not really sure what you're upto... but post 15 of this thread may help:
http://community.actinic.com/showthread.php?t=30805
You have to copy/paste and then tinker :-)
Comment
-
Originally posted by gabrielcrowe View Postbtw: untested, but this is how it SHOULD work.
@bentleybloke
Out of curiosity I tried the suggested code and it works fine with strings but not integers. Try the following and you'll see what I mean:
Code:<actinic:block php="true" > $itemno = 0; $test = 'bath'; </actinic:block> <actinic:block if="%24itemno%3d%3d0" > $itemno == 0<br> </actinic:block> <actinic:block if="%24test%20%3d%3d%3d%20%27bath%27" > $test === 'bath'<br> </actinic:block>
Comment
-
PHP variables in if statements is a nightmare. The example you've posted above doesn't work for strings either.
If you change
$test = 'bath';
to
$test = 'XXX';
the comparison seems to return true.
It would seem that only constants, php intrinsic functions and Variables work properly.Norman - www.drillpine.biz
Edinburgh, U K / Bitez, Turkey
Comment
-
Hahahaha. </hysterical> It doesn't do that here. Perhaps it's a difference between 8 and 9. Either way, it's not a feature I'd care to rely on.
This all makes it a complete bugger to get data back out from a php statement Your only option is an echo, which stops you from writing elegant presentational markup.
Comment
-
I tend to use pure PHP and HEREDOC syntax.
E.g.
Code:<actinic:block php="true"> if ( $variable == <actinic:variable name="AnotherVariable" /> ) $html = <<<ENDOFCODE miscellaneous layouts here ENDOFCODE; echo $html; </actinic:block>
Of course what I'd really like is a reliable way of using pre defined PHP variables in a blockif.Norman - www.drillpine.biz
Edinburgh, U K / Bitez, Turkey
Comment
Comment