Partial View Script in FlashMessanger

旧城冷巷雨未停 提交于 2019-12-13 04:29:16

问题


Is there a way to parse a partial view script as a flash message?

Iam using some big flash messages with html code blocks in it and the ability to read or format those messages is really bad.


回答1:


There's several ways to address the issue you're talking about and cptnk offered you one. However so much code within View-Files isn't often something you want. Luckily ZF2 offers a way to configure the same thing via configuration, too:

'view_helper_config' => array(
    'flashmessenger' => array(
        'message_open_format'      => '<ul><li>',
        'message_separator_string' => '</li><li>',
        'message_close_string'     => '</li></ul>'
    )
)

This has all been covered within the official documentation by me quite a time ago including an example of a Twitter Bootstrap 3 FlashMessenger layout. You may want to check this out for yourself.

And to give you a straight out answer to your initial question: no it's not possible to have a dedicated view-file to be used by the flashMessenger plugin. You'd have to write your own flashMessenger implementation for this.




回答2:


Did you take a look at the html layouting the view helper offers?

echo $this->flashMessenger()
  ->setMessageOpenFormat('<div%s><p>')
  ->setMessageSeparatorString('</p><p>')
  ->setMessageCloseString('</p></div>')
  ->render('success');

This example create's a div with the class success and nested "p's". When adding some more tag's to the setMessageOpenFormat make sure to close them with the setMessageCloseString.




回答3:


How about make partial and pass flashMessenger to it ?

<?php // partial.phtml ?>

flashMassenger: <pre><?php var_dump($this->flashMassenger) ?></pre>

You would then call it from your view script using the following:

<?php echo $this->partial('partial.phtml', array(
    'flashMassenger' => $this->flashMessenger())); ?>


来源:https://stackoverflow.com/questions/22399861/partial-view-script-in-flashmessanger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!