if (array_key_exists('assign', $params) and $params['assign']) {
// we are assigning the data here
$smarty->assign($params['assign'], $actionForm->$method());
} else {
// there was no assignment request, so return it raw
return $actionForm->$method();
}
}
?>
ralph
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Como fao para ler variaveis no escopo PHP junto com variaveis do escopo SMARTY?
Sorry, but dont speak spanish. Write your message in english please.
Thank you
Tim
OK!
Excuse me. I dont write very well.
How can I do to read variables of php escope with variables into SMARTY escope? Mix.
Thanks!
I don't know whether I have understood you correctly. Here one small example.
struts4php ActionForm:
<?PHP
class PersSettings extends ActionForm {
var $eMail;
public function &geteMail() {
return $this->eMail;
}
public function seteMail($eMail) {
$this->eMail = $eMail;
}
public function reset( $actionMapping ) {
$this->eMail = null;
}
public function validate( $actionMapping, &$request ) {}
}
?>
smarty form:
{struts4php field='eMail'}
or
{struts4php field='eMail' assign='email'} to assign it to smarty's variable {$email}
here the smarty plugin:
<?PHP
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.struts4php.php
* Type: function
* Name: struts4php
* Purpose: return the field's value
* -------------------------------------------------------------
*/
function smarty_function_struts4php($params, &$smarty)
{
global $request, $actionBanana;
$field = $params['field'];
$method = 'get%s';
$method = sprintf($method, $field);
$actionMapping = $actionBanana->findMapping($request->getAttribute(PATH));
$actionForm = $request->getAttribute($actionMapping->getName());
if (array_key_exists('assign', $params) and $params['assign']) {
// we are assigning the data here
$smarty->assign($params['assign'], $actionForm->$method());
} else {
// there was no assignment request, so return it raw
return $actionForm->$method();
}
}
?>
ralph