Smarty framwork assign, get variable from php function, and foreach cycle

Helo,

how write this correctly

{foreach from=$category item = parent}

{foreach from=categoriesChild($parent.parent_id) item=cat}

do somthing

{/foreach}
{/foreach}

categoriesChild is function who get categorys from database where parent_id. How write this correct.

If be only php then be easy :). This is part of modifikation CMS made simple, blog module