Code Monkey home page Code Monkey logo

Comments (11)

ababic avatar ababic commented on June 7, 2024

Hi @dwasyl. Thanks for the input. I take it this idea has come out of frustration in using wagtailmenus on a multisite project? If so, it'd be great to hear more about that setup (how the page tree is broken up... what is similar across sites, what is different etc). I suppose I always assumed multisite projects would rarely share any pages across sites, and so duplicating a menu for use on a different site wouldn't be that useful, as you'd have to change every item to link to a different page anyway. That's just based on my experience, though, yours may well be different?

from wagtailmenus.

dwasyl avatar dwasyl commented on June 7, 2024

My pleasure @ababic! Wagtailmenus has been great, super easy to implement so far, although I've been trying to use it to develop sidebar menus/navs as well. That's definitely where my request came from.

In my case, the multisite project is basically taking consistent look & feel web project onto separate properties. The web trees don't really share any pages, although, they do generally share the same header/footer menus (and definitely not sharing the same Main Menu). I would hardcode the header/footer menus in, but there are some limited circumstances where change/customization could be required. Due to this, keeping the menus separate (rather than shared) is good, but being able to duplicate one entirely would be very useful.

The required look and feel means that certain things, like header and footer or even some other menus would be the same/similar between sites, although no other content would be the same. Does the use case make sense? Let me know if I wasn't clear enough.

from wagtailmenus.

ababic avatar ababic commented on June 7, 2024

Hi @dwasyl. Thanks. It's great to have your insight! Can I just ask why you aren't using the section_menu tag for side menus? Is it because the sites use a lot of apps that are routed via URLs, and so you aren't serving actual wagtail Page objects a lot of the time (section_menu currently only works when serving a 'Page', so it can figure out what to render)? Or are you adding a lot of links to things that aren't pages?

from wagtailmenus.

ababic avatar ababic commented on June 7, 2024

Sorry for all the questions :) I'm thinking that with some small adjustments elsewhere to make things easier to use in different situations, it may well solve the problem for most people.

from wagtailmenus.

ababic avatar ababic commented on June 7, 2024

Hi @dwasyl I've raised #23 in order to better explain what I was getting at earlier. I still think the idea of having a 'Duplicate' feature for flat menus has merit. The admin side of things is using the wagtail.contrib.modeladmin app to hook into wagtail, which I know supports the addition of urls/views and a new button.

Is this something you'd feel comfortable tackling yourself and adding via a pull request?

from wagtailmenus.

dwasyl avatar dwasyl commented on June 7, 2024

Well, I am using section_menu where possible, but I have a number of side menus that have outside links. As well, I'm trying to build a menu that generates links based on the document using JavaScript (sort of a Table of Contents menu).

Let me take a look at the code to see if I can figure out how to add the feature/button myself. I'm happy to try sending a PR.

from wagtailmenus.

ababic avatar ababic commented on June 7, 2024

Thanks @dwasyl, I wrote the modeladmin app, so allow me to point you in the right direction:

Adding the button:

  • You need to create a new ButtonHelper class (sub-classing wagtail.contrib.modeladmin.helpers.ButtonHelper), and add a button_helper_class attribute on wagtailmenus.wagtail_hooks.FlatMenuAdmin to point at it.
  • The button helper class will need a new duplicate_button method to define the button (you can probably copy edit_button as a starting point)
  • You'll then need to override the get_buttons_for_obj method to add that button into a list with the others.
  • I think it would be sensible to add some logic inside get_buttons_for_obj to only add the duplicate button if there are Site objects that don't yet have a flat menu with the same handle.

Creating a view:

This will be where most of the work is needed. It's probably best to sub-class wagtail.contrib.modeladmin.InstanceSpecificView as your starting point and work from there. For an example of getting a simple form into a view, you should use the ChooseParentView as a guide.

Linking the new view into FlatMenuAdmin:

from wagtailmenus.

dwasyl avatar dwasyl commented on June 7, 2024

Alright - thanks for the directions :) I was away for a few days, but I'm going to try and tackle this this week or next.

I will also update the display code, as right now if two menus have the same name on different sites it is difficult to differentiate them (since nothing about the site name appears in the display).

from wagtailmenus.

ababic avatar ababic commented on June 7, 2024

Sounds great! Let me know if you run into any blockers :)

from wagtailmenus.

dwasyl avatar dwasyl commented on June 7, 2024

Had a few days delay with another project so this got delayed slightly, but still on the list for soon :)

from wagtailmenus.

ababic avatar ababic commented on June 7, 2024

Not a problem, @dwasyl. In the meantime, I might tweak the listing to include the site name, as that's a small change, and something that should really be there already.

from wagtailmenus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.