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

how to make menu with icon #306

Open
NguyenDucTruong123 opened this issue Jul 21, 2023 · 1 comment
Open

how to make menu with icon #306

NguyenDucTruong123 opened this issue Jul 21, 2023 · 1 comment

Comments

@NguyenDucTruong123
Copy link

Hi everybody . I want to build a menu and have an icon. So how should I do it? I don't know how to pass pictures in
I have the code

private function createMenus($menu, $aMenus, $parent_id)
{
foreach ($aMenus as $oMenu) {
if ($oMenu->parent_id == $parent_id) {
$submenu = $menu->add($oMenu->name, "danh-muc-san-pham/" . $oMenu->path);
$this->createMenus($submenu, $aMenus, $oMenu->id);
}
}
}

@nkhoangvu
Copy link

nkhoangvu commented May 31, 2024

You should use prepend() to add icon before link or append() to add icon after link.
For example using FontAwaresome Icons:
$menu->add($oMenu->name, "danh-muc-san-pham/" . $oMenu->path)->prepend('<i class="fa-solid fa-briefcase"></i>');

Or another way, you can use only icon without text, replace $oMenu->name with the icons tag:
$menu->add('<i class="fa-solid fa-briefcase"></i>', "danh-muc-san-pham/" . $oMenu->path);
Hope this help.

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

2 participants