Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Peredacha peremennoi v shablon

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Russian
View previous topic :: View next topic  
Author Message
DEA7H
Smarty Rookie


Joined: 22 Nov 2012
Posts: 10

PostPosted: Thu Nov 22, 2012 8:52 pm    Post subject: Peredacha peremennoi v shablon Reply with quote

Здравствуйте!
Как просто передать переменную в нужный мне файлик .tpl?

Я делаю вот так:
Code:
$content = $template->fetch("news.tpl");
$template->assign('content',$content);
$template->assign('row',$row);
   
$template->display($_SERVER['DOCUMENT_ROOT']."/templates/default/main.tpl");

Тоесть, я передаю переменную row в файлик main.tpl. Передается переменная когда срабатывает вот эта строчка.

А мне нужно тут же передать эту переменную в файл news.tpl, тоесть передать ее и main.tpl и в news.tpl. Она мне нужна в news.tpl поскольку я юзаю:
Code:
$content = $template->fetch("news.tpl");
$template->assign('content',$content);


Как такое сделать?
Заранее благодарен.
Back to top
View user's profile Send private message
DEA7H
Smarty Rookie


Joined: 22 Nov 2012
Posts: 10

PostPosted: Thu Nov 22, 2012 10:39 pm    Post subject: Reply with quote

Сказали сделать вот так:
Code:
$template->assign('row',$row);
$content = $template->fetch("news.tpl");
$template->assign('content',$content);
 
$template->display($_SERVER['DOCUMENT_ROOT']."/templates/default/main.tpl");


Тоесть assign('row',$row) поместить перед $template->fetch("news.tpl");. Это действительно работает. Но только не в моем случае!

Вот код самого NEWS.TPL:

Code:
{foreach $row as $items}
    <div class="centerblock">
        <div class="headertxt">{$items.id}</div>
        <div class="contentinfo">{$items.name}</div>
       
            {$items.story}
 
    </div>
{/foreach}


Подскажите возможно чтото не так в цикле или проблемы с использованием ассоциативного масиива.

Заранее благодарен.
Back to top
View user's profile Send private message
DEA7H
Smarty Rookie


Joined: 22 Nov 2012
Posts: 10

PostPosted: Thu Nov 22, 2012 11:04 pm    Post subject: Reply with quote

Проблема решена!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Russian All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP