0

I have this smarty template, I need to call a function from my file.

Everything works fine, php recognizes the parameters, but not the values of the smarty variables. Code:

{insert name=file_details value=a assign=fd fid=$m[i].FID}
<ul class='list'>
    {section name=x loop=$fd}
        {insert name=gfs assign=afs a=$fd[x]}
        <li><a href="{$baseurl}/files/{$fd[x].FID|md5}{$fd[x].s}/{$fd[x].fname}" target="_blank">
        {$fd[x].fname} <b>[{$afs}]</b>
        </a></li>
    {/section}
</ul>

Meaning. the first insert retrieves some file information from my database, using as parameter $m[i].FID everything works fine, when I tell him for example {$fd[x].fname} it displays the name of the file, but when I tell him {insert name=gfs assign=afs a=$fd[x]} and make a var_dump(a) in the function insert_gfs all the values appear as null.

Any help would be great, I don't know what i'm missing

1 Answer 1

0

Arrays are writen as $m.i in Smarty. Not $m[i].

If you replace all your array notations like this, it should work.

{insert name=file_details value=a assign=fd fid=$m.i.FID}
<ul class='list'>
    {section name=x loop=$fd}
        {insert name=gfs assign=afs a=$fd.x}
        <li><a href="{$baseurl}/files/{$fd.x.FID|md5}{$fd.x.s}/{$fd.x.fname}" target="_blank">
        {$fd.x.fname} <b>[{$afs}]</b>
        </a></li>
    {/section}
</ul>
Sign up to request clarification or add additional context in comments.

1 Comment

thanks, at the end, I had to rewrite that function, it apparently was failing to get the parammeters when i called {insert name=gfs assign=afs a=$fd.x}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.