English 中文(简体)
辛勤工作
原标题:Flash-Messages in Symfony2 doesn t seem to work in my twig-template

I want to add support for flash messages on our pages. I implemented this by following the documentation found here.

I added the following snipplet to my base layout. (i also tried to add it to a specific action template).

{% if app.session.hasFlash( notice ) %} 
    <div id="flashmessage" class="flash-notice"> 
       {{ app.session.flash( notice ) }} 
   </div> 
{% endif %} 

在添加以下错误之后,就推倒了:

Twig_Error_Runtime: 在“MyBundle:layout.html.twig”第66行中不存在“斜线”项目。

是否有任何东西需要做?

问题回答

您是否使用2.0或2.1(目前为总务)?

http://symfony.com/doc/2.1/book/ Controller.html#flash-messages”rel=“noreferer” http://symfony.com/doc/2.1/book/ Controller.html#flash-mesages

闪电如上所示:

{% for flashMessage in app.session.flashbag.get( notice ) %}
    <div class="flash-notice">
        {{ flashMessage }}
    </div>
{% endfor %}

3. 您的议事录中的哺乳动物检查:您自始至终:

session:
    default_locale: %locale%
    auto_start:     true

由于错误似乎是Twig没有找到会议类别,而没有涉及激烈的职能。 事实上,在我的布局中,我几乎完全有相同的法典。

这在撰写本报告时相当老,这样可以想象到,现在你会提出,但为了参考,它有<条码>、<>条/代码>而不是<条码>。 因此。

{% if app.session.flashbag.has( notice ) %} 
    <div id="flashmessage" class="flash-notice"> 
       {{ app.session.flashbag.get( notice ) }} 
   </div> 
{% endif %} 

缩略语2.6

{% if app.session.flashbag.has( notice ) %}
    {{ app.session.flashbag.get( notice ).0 }}<br/>
{% endif %}

由于热点是这一版本的阵列,你需要加以压缩或使用索引。 使用指数的Im,因为I dont需要更多的东西。

In controller

$this->get( session )->getFlashBag()->add( notice ,  Your message! );

页: 1

{% for flashMessage in app.session.flashbag.get( notice ) %}
    <div class="alert alert-warning">{{ flashMessage }}</div>
{% endfor %}  

我只想指出,如果<>条码>-redirects是真的,那么闪电就不会奏效。

你们的行动中是否定下了闪电?

$this->get( session )->setFlash( notice ,  Your changes were saved! );

将闪电信息储存在用户会议上,具体来说是one





相关问题
Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

How to create a submit button template in Oracle APEX?

I m trying to create a template for a button in Oracle APEX but I don t seem to have access to the appropriate substitution strings to make it work. For non-templated buttons APEX seems to insert a ...

list of controls with templates in silverlight

Does anyone know where to find a list of controls that you can set the template on in Silverlight? I ve wasted several hours now trying to create control templates only to find that the control doesn ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Load ruby on rails template from database

I wonder if there is a way for me to store ruby on rails view files into database store and have that fetched directly from there. The reason is I want to create a CMS with all the user data stored in ...

Templated HTML Editor

I m looking for a HTML editor that kinda supports templated editing or live snippets or something like that. Background: I m working on a website for a friend. As there are no specifications what the ...

Dreamweaver changing path to site s reference instead of local

I have noticed recently, when I apply a template to a new HTML website, all the relative paths are pointed to my local files, example: file:///C|/webstuff/files but I cannot set them to relative paths ...

WPF ListView : Header styling

I want to have a ListView with columns and a particular style: The background for ALL column headers should be transparent except when the mouse is over in one of them. When this happends, the ...

热门标签