zendframework / zend-mvc-plugin-flashmessenger

BSD 3-Clause "New" or "Revised" License
7 stars 8 forks source link

view_helper_config flashmessenger key to support multiple namespaces. #11

Open alextech opened 7 years ago

alextech commented 7 years ago

I would like to propose a feature (I can implement myself if useful) that allows to optionally specify additional keys in view helper configuration for templates per namespace. Currently, if even a single namespace needs to have different template, need to fully take out configuration and copy/paste all 5 namespaces in an html template. I think may help to match configuration with full capability of what renderer can do. If flashmessenger is one dimensional array, continue to apply that template to all namespaces. If some namespaces are listed, apply specified template and default template to unlisted.

'view_helper_config' => [
    'flashmessenger' => [
      'success' => [
            'message_open_format'      => '<div%s><ul><li>',
             'message_separator_string' => '</li><li>',
             'message_close_string'     => '</li></ul></div>',
        ]

       'warning' => [
            'message_open_format'      => '<div%s><button type="button" class="close"
               data-dismiss="alert" aria-hidden="true">&times;</button><ul><li>',
             'message_separator_string' => '</li><li>',
             'message_close_string'     => '</li></ul></div>',
        ]
    ],

    'default' => [
       ....
     ]
],

If this is useful, then I can do it. But since this is a view helper task, do not know procedure of writing against PR that is not going to be accepted for a while https://github.com/zendframework/zend-mvc-plugin-flashmessenger/pull/10, which ports the view helper from zend view to mvc plugin.

froschdesign commented 7 years ago

@alextech Don't forget the classes:

'view_helper_config' => [
    'flashmessenger' => [
        Zend\Mvc\Plugin\FlashMessenger\FlashMessenger::NAMESPACE_ERROR => [
            'classes'                  => 'alert-box alert',
            'message_open_format'      => '<p%s>',
            'message_close_string'     => '</p>',
            'message_separator_string' => '<br>',
        ],
        // …
    ],
],
alextech commented 7 years ago

Thank you, that would have been horrible oversight.

weierophinney commented 4 years ago

This repository has been closed and moved to laminas/laminas-mvc-plugin-flashmessenger; a new issue has been opened at https://github.com/laminas/laminas-mvc-plugin-flashmessenger/issues/3.