Smarty is a bit of a pain in that it doesn't allow you to embed the output of PHP functions directly in the template (except in {if} tags for evaluating conditions).
You can call methods of objects that are part of the Smarty context and this is a way to get around many things. For example you can access the record of the currently logged in user (a Dataface_Record object) using the $ENV.user variable inside a smarty template. Therefore any method on this record could be called.
You could then create a custom field in your users table delegate class that you could access from the smarty template. E.g.:
- Code: Select all
function field__my_program_id($record){
return $record->val('ProgramID');
}
Then in your smarty template:
- Code: Select all
{if $ENV.user}
Program id is {$ENV.user->val('my_program_id')}
{/if}
You may notice, however, if you're using this approach you actually didn't need to create a custom field for the program ID since that field already exists. You could have just accessed the field directly from smarty:
- Code: Select all
{if $ENV.user}
Program id is {$ENV.user->val('ProgramID')}
{/if}
Best regards
Steve