Так в функции smarty получится т.к. в нее передается $smarty:
<?php function smarty_function_xxx($params, & $smarty) { $modx = & $smarty->modx; ... }