Thread:Extension talk:Widgets/Using a function in a variable value

I'm trying to create a widget for ReseacherId. The problem there is that the HTML code of a ResearcherId Badge requires a unique element ID at two places in the code (in this case the id is badgeCont983337): 

I have tried to generate this id and store it in a Smarty template to be able to reuse it, but to no avail. What I tried looks like the following. I have also tried various variants.

 The problem seems to be that the function counter is not called when the template elid is created. How can I do this? What am I doing wrong?