Php variables in tpl

Hello,
I’m trying to write a module altering a couple of templates. My problem is that I can’t seem to assign variables defined in a php file to use them in a tpl file. I gathered the way to do this is via

$var = ‘whatever’;
$smarty->assign(‘var’, $var);

However, the variable doesn’t seem to be assigned correctly as it is not listed in the templates variables list retrieved by [{debug}] and as a result the field were the variable is supposed to be shown ends up being null.

I managed to assign variables in the tpl file directly with
[{assign var=test value=“whatever” scope=“global”}]
and can also use this one in another tpl.

Does anyone have an idea what it is that went wrong or that I am missing?

this might be useful for you:
http://forum.oxid-esales.com/showthread.php?t=24118

http://www.foxido.de/php-smarty-datenaustausch