Hello!
How can I just transfer a variable to the .tpl file I need?

I do this:

$content = $template->fetch("news.tpl"); $template->assign('content',$content); $template->assign('row',$row); $template->display($_SERVER['DOCUMENT_ROOT']."/templates/default/main.tpl"); 

Ie, I pass the row variable to the main.tpl file. A variable is passed when this line is triggered.

And I need to immediately transfer this variable to the file news.tpl, that is, transfer it to both main.tpl and to news.tpl. I need it in news.tpl since I use it:

 $content = $template->fetch("news.tpl"); $template->assign('content',$content); 

How to do this?
Thanks in advance.

    1 answer 1

     $template->assign('row', $row); 

    Take it up

     $template->fetch("news.tpl"); 

    Those.:

     $template->assign('row', $row); $content = $template->fetch("news.tpl"); $template->assign('content', $content); $template->display($_SERVER['DOCUMENT_ROOT']."/templates/default/main.tpl"); 
    • No, that doesn't work. Everything remained unchanged. More options? - DEA7H
    • But no, this structure generally works. Only here in my version does not want. Maybe something is wrong with the cycle. {foreach $ row as $ key => $ items} <div class = "centerblock"> <div class = "headertxt"> {$ items.id} </ div> <div class = "contentinfo"> {$ items. name} </ div> {$ items.story} </ div> {/ foreach} - DEA7H
    • Problem solved! - DEA7H