-
Notifications
You must be signed in to change notification settings - Fork 201
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
Changing the HTML strcture of a menu should be easy #329
Comments
semantically the ul / li seems the correct thing to do. but if there is
a good use case for more flexibility, we should make the template more
flexible, yes. probably like its done for ul already, see
knp_menu_ordered.html.twig
can you explain why you need div? and does needing div not mean that the
rest of your template also needs to be specific because you use the menu
in some different way?
|
Hi @dbu, I agree that generally the ul/li is the common way to rendere a menu. However sometimes a differente structure is needed, for example when the menu should look like a Bootstrap grid. In that case the root is usually a Another good reason to make a start/end tag block is to force CSS classes, without writing classes in PHP itself. In this case you can set classes right before opening the tag. Right now I'm using a custom base menu template with 4 new blocks:
|
@stof how would you feel about a refactoring as gremo proposes? it seems safe enough to me, and would be BC as its just adding new blocks. |
Any update on this? Thanks. |
As the Adding 2 extra blocks around the opening and closing tags looks overkill to me. And it would have a performance impact: any Twig block involves a function call (actually several ones due to first reaching some Twig internal layer which is then calling the function rendering the block). As these blocks are called a lot when rendering a menu, I'm not sure this is a good idea. |
ATM if you need to change the HTML structure - i.e. from ul/li to div/div - you need to copy and past the whole
knp_menu.html.twig
. For thelist
block this is a matter of a few lines, but for theitem
block there a lot of lines.This seems uncomfortable to me. How about adding a block for just print the HTML tag? This way when
knp_menu.html.twig
will be update my menu will be update too.The text was updated successfully, but these errors were encountered: