Reputation: 8790
I cannot assign my own PHP function. (I just have access to the TPL file).
So far I got {$smarty.server.PHP_SELF}
, which returns something like /foo/bar.xin
. With built in functions, I'd like to get /foo/
.
Upvotes: 0
Views: 1960
Reputation: 28210
{$smarty.server.PHP_SELF | dirname}
will return /foo
assuming the dirname function is enabled (see php_modifiers
in Smarty security settings).
Upvotes: 1
Reputation: 49238
As I noted, {php}
tags are deprecated, but you can do the following:
{php}
$php_self = $_SERVER['PHP_SELF'];
$path = substr($php_self, 0, strrpos($php_self, '/'));
// assign a variable to Smarty
$this->assign('path',$path);
{/php}
Path: <strong>{$path}</strong>
I haven't been able to test this, since I don't have a parser at my disposal, but it follows the example on the Smarty documentation page:
http://www.smarty.net/docs/en/language.function.php.tpl
Upvotes: 1