Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use custom templates for message/template items #86

Open
MartinLyne opened this issue Jan 13, 2016 · 1 comment
Open

Comments

@MartinLyne
Copy link

So I just got into using notifications and feel that the messages have an overly strict template. Fixed date format, requires a from-user and click url.

Wanted to gather some thoughts, expanding the Interface/s to require a getTemplateName ("YourBundle::template.html.twig") that replaces the normal template if found.

I'm still mulling that in my head. the alternative is.. I make a whole new event, a more generic notification that allows you to customise the navbar icon (currently stuck with bell for general, envelope for message) and uses the same custom template solution as above for rendering each item.

Currently got a bad cold, so if any of this has an easier solution or just sounds like fever dreams, please, let me know.

@avanzu
Copy link
Owner

avanzu commented Jan 14, 2016

A general solution would be to use a single kind of navbar event which provides some kind of attributed storage (like the session flashbag does).
Like so:

$event->getBag()->add('notification', new Notification()); 

Navbar segments would then be rendered using the attribute name to determine the actual twig template like so:

{% for type, items in bag %}
{% include 'YourBundle::' ~ type ~ 'html.twig' with { "items" : items } %}
{%endfor %}

In order to simplify the actual template markup, using a macro or generalized embed might be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants