This topic is locked

Using literals in php code snippets

5/23/2009 11:47:13 PM
PHPRunner General questions
G
giles author

Hi,

Is there a way to use a literal in a php code snippet?
For example:

Pass the value of the field Notes in a list paqge {$row.1Notes_value} to the code snippet....

J
Jane 5/25/2009

Hi,
unfortunately no.

You need to select this value in your event manually.

G
giles author 5/31/2009

Hi Jane,

I found another way to work out what I was trying to do - will post it in the tips forum as it may benefit some-one else...
A way of passing a literal to a php code snippet did occur to me...
From the Visual Editor use the custom validation to set a session variable....

e.g.

$value = strtoupper($value); // Or whatever processing is needed...

$_SESSION["mysessionvariable"] = $value;
Then php can access the session variable.
This will probably work for edit/view pages altough there are other ways to get the field value for these pages.
For list pages the session variable the code snippet picked up was always the value of the field in that last row displayed even though the code did everything else correctly for each row. Not sure why the code snippet would run for each row but not get the value of the session variable set for that row... Pity, it looked a novel approach.