This topic is locked

access variables in php snippets in html edit page

3/24/2009 1:40:23 PM
PHPRunner General questions
N
nbrennan author

I am trying to display text on the visual editor, and I want to use the php snippet function to check to see if a field is set a certain way....
How do I refer to that field?
In the events editor, I know its $values["fieldname"] but that does not work on the visual editor.
basically, I want to be able to do something like

if ($values["fieldname"] != 0)

{

do something;

}
Admin 3/24/2009

It depends on which page you need to apply this logic to.
I recommend to check PHPRunner manual in this regard that explains how to manipulate template variables:

http://www.xlinesoft.com/phprunner/docs/smarty_templates.htm

N
nbrennan author 3/24/2009

It depends on which page you need to apply this logic to.

I recommend to check PHPRunner manual in this regard that explains how to manipulate template variables:

http://www.xlinesoft.com/phprunner/docs/smarty_templates.htm


Yeah, I looked through that, but it doesn't make a lot of sense to me, unfortunately.
I'm on the _view.php file, trying to use the button that says "onscreen event" which creates a function called "projectsmain_Snippet2(&$params)."
I want to check to see if one of the values is set to a specific value. Is there a way to do it?

Admin 3/24/2009

If you want to use "Insert PHP code snippet" function on View page you can refer to field values the following way:

global $data;

echo $data["FieldName"];
N
nbrennan author 3/26/2009

If you want to use "Insert PHP code snippet" function on View page you can refer to field values the following way:


global $data;

echo $data["FieldName"];


Sweet, thanks, that's much easier than the roundabout way I figured how to do it.

E
eloi 4/1/2009

I want do something like this in List Page. I want to print variables in any record lines.
I do this:

function transaccio_Snippet3(&$params)

{

global $record;
echo $record["FieldName"];
} // function transaccio_Snippet3


but it doesn't work. It prints only the last register line.
Thank for your help!

J
Jane 4/1/2009

Hi,
you code means nothing.

Please give me more detailed description of what you want to achieve and I'll try to help you.

jwoker 4/7/2009

If you want to use "Insert PHP code snippet" function on View page you can refer to field values the following way:


global $data;

echo $data["FieldName"];


I would like to use "Insert PHP code snippet" function on a List page --> printer friendly view. The field values i would access to is from the Master table info print -- Though -- accessing data from any of the List page list items would work as well.
Also, what information is contained in &$params?
Thanks

J
Jane 4/8/2009

Hi,
this code works for view page only.

To change field values on the list/print page use After record processed event and $record global array.

Also you can change field values manually on the "View as" settings --> Custom dialog on the Visual Editor tab. Unfortunately there is no reliable way to select field values for each row in custom events on the list/print pages.
$params contains event name only.