A property which is set in JS e.g. nuSetProperty('myname','Bruce Bogtrotter') can be retrieved in PHP with the construct $nm = "#myname#"
This works fine but does have a few drawbacks most notably, if the property (hash cookie) has not been set, the variable takes the value of the hash cookie place holder itself.
To address this, and to provide consistency between JS and PHP code, we have introduced the PHP functions nuSetProperty() and nuGetProperty().
As much as possible, these behave like their JS equivalents, using the same parameters. Consider the following statements:
Code: Select all
$nma = "#myname#" ; // A
$nmb = nuGetProperty("myname"); // B
Please note the following caveats.
- If a global property is set in PHP, the value does not become available to JS until a new form is loaded. If you want the property to be available without loading a new form, then nuJavascriptCallback() can be used to set the property explicitly in JS.
- Be careful with naming. It is good practice to avoid using the same property name for both form (local) and global properties. The issues are analogous to scope-related confusions that can arise in programming languages.
- In PHP, nuGetProperty() will return null if the property does not exist/has not been set.
Please report back any issues (or suggestions) here on the forum.
Many thanks,
Neil