iommirocks / iommi

Your first pick for a django power cord
http://iommi.rocks
BSD 3-Clause "New" or "Revised" License
718 stars 47 forks source link

Nested menus #411

Open djjudas21 opened 1 year ago

djjudas21 commented 1 year ago

I'm beginning to use iommi to refactor my django project, which uses a lot of custom templates etc. I've figured out how to map most of my features across to iommi features to simplify my codebase, but one thing I haven't found yet is a way to implement nested menus.

This is how I'm using Bootstrap menus at the moment: https://camerahub.info/

Is this kind of behaviour possibly with iommi? Thanks

boxed commented 1 year ago

You can, but if your menus aren't very dynamic and you've already written them, you should probably keep using the menus you have, via your base template and maybe come context processor.

How did you render menus before?

djjudas21 commented 1 year ago

My menus are just chunks of plain HTML with Boostrap, in a Django template file: https://github.com/camerahub/camerahub/blob/master/schema/templates/nav.html

They're pretty simple, and they work, but it's not pretty :slightly_smiling_face:

djjudas21 commented 1 year ago

Follow-up question... is it possible to include a template in a Page by reference to its template filename? My menu is defined in nav.html and just gets included into my old template. Is there an easy way to carry this over with iommi? Something like:

menu = Template('nav.html')
boxed commented 1 year ago

@djjudas21

menu = Fragment(template='nav.html')