PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, January 19, 2022

[FIXED] Passing a list of menu items to the sidebar in Backpack Laravel

 January 19, 2022     laravel, laravel-backpack, laravel-blade, php     No comments   

Issue

I'm trying to send a list to sidebar_content.blade.php. The idea would be getting the menu items from a database. I guess I should add the variable to the @include in every subview in the "chain", but I don't know which controller (if any) starts that chain.

I have read the docs and tried to find tutorials, projects or people asking similar things, but I found nothing. I know how to get the menu items from inside sidebar_content.blade.php, but that looks wrong.

How should I go about doing this? I'm extremely new to both Laravel and Backpack, so it's very likely that I'm misunderstanding something basic.


Solution

The easiest way would be to get the entries right there in sidebar_content.blade.php.

But like you said, it's probably a good idea to separate the entry-getting logic. The easiest way to do that would be to include a custom view inside sidebar_content, maybe something like... database_sidebar_entries.blade.php... and put your DB logic inside a Laravel view composer.



Answered By - tabacitu
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing