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

[question] Add subnavigation tabs/links #196

Closed
gavinhewitt opened this issue Oct 22, 2016 · 4 comments
Closed

[question] Add subnavigation tabs/links #196

gavinhewitt opened this issue Oct 22, 2016 · 4 comments

Comments

@gavinhewitt
Copy link

gavinhewitt commented Oct 22, 2016

I'm breaking my head over this and could use some help figuring it out (if even possible).

I'm trying to find a way to add subnavigation to one of the models/entities. I use backpack to admin some sort of e-commerce site that has multiple stores with each their own settings (general, design, products, etc.). I would like to add subnavigation for the selected store (/store/1/general, /store/1/design etc). Maybe I'm just not seeing it but how to achieve this in true backpack fashion?

I thought about a possible solution and tried it as proof of concept but it didn't work:

  • add a new trait called SubNav, basically the same setup as how buttons work
  • add a BaseStoreCrudController (extends CrudController) and extend StoreGeneralCrudController etc from that
  • in the BaseStoreCrudController call $this->addSubNavLink([settings_here])
  • add the required code for displaying in the view(s)

This doesn't work because it chokes on:
$this->subnav->push(new SubNavLink($placement, $name, $type, $content));

Call to a member function push() on null

If $this->addSubNavLink([settings_here]) is set in the basecontroller, $this->subnav is null, if I set it in StoreGeneralCrudController it works (but this is not the place for it).

Any ideas?

@gavinhewitt
Copy link
Author

Umm, of course. initSubNav() is triggered upon setRoute() (which is called in StoreGeneralCrudController) and therefore null because you can't addSubNavLink before init. Makes sense (duhh). Obvious solution is to move setRoute() and other settings to the basecontroller.

@tabacitu
Copy link
Member

Hmm... When you say settings do you mean "settings" or "entities", as in different CRUDS? If you mean nested cruds, take a look at this answer here: #82 (comment). I'm not 100% sure that's what you're looking for.

Cheers!

@gavinhewitt
Copy link
Author

With settings I mean stuff like setModel() and setRoute()

@OwenMelbz
Copy link
Contributor

I'm just tidying up some bits, so closing this off as its quite old now, if you guys feel the need to reopen, thats all good!

This was referenced Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants