laminas / laminas-mvc-plugin-flashmessenger

Plugin for creating and exposing flash messages via laminas-mvc controllers
https://docs.laminas.dev/laminas-mvc-plugin-flashmessenger/
BSD 3-Clause "New" or "Revised" License
10 stars 16 forks source link

view_helper_config flashmessenger key to support multiple namespaces. #3

Closed weierophinney closed 2 years ago

weierophinney commented 4 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.


Originally posted by @alextech at https://github.com/zendframework/zend-mvc-plugin-flashmessenger/issues/11

weierophinney commented 4 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>',
        ],
        // …
    ],
],

Originally posted by @froschdesign at https://github.com/zendframework/zend-mvc-plugin-flashmessenger/issues/11#issuecomment-271545859

weierophinney commented 4 years ago

Thank you, that would have been horrible oversight.


Originally posted by @alextech at https://github.com/zendframework/zend-mvc-plugin-flashmessenger/issues/11#issuecomment-271616037

Ocramius commented 2 years ago

Handled in #25