Adding Extra Links to NavMenu

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
jrcervantest
Veteran Member
Posts: 32
Joined: 2020-06-22 00:00

Adding Extra Links to NavMenu

Post by jrcervantest » 2020-07-08 15:58

I’m adding a custom link to the navigation menu. When I add a value that exceeds the # of table groups, it creates its own group, which is great, but it doesn’t have a header title. Is their syntax within the array section that would create a title for that additional stand-alone table group? Thank you. V/r,

// file: hooks/links-navmenu.php (syntax below is intentionally abbreviated for the purposes of this post)

$navLinks[] = array(
'url' => 'hooks/summary-reports-list.php',
'title' => 'XXXX',
'groups' => array('*'),
'icon' => 'hooks/summary_reports-logo-md.png',
'table_group' => 4, // optional index of table group, default is 0,

);
Attachments
2.PNG
2.PNG (16.29 KiB) Viewed 2553 times

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Adding Extra Links to NavMenu

Post by pbottcher » 2020-07-08 19:19

Hi,

I would not know of any option to set this directly.

But you could add the following to the hooks/footer-extras.php

Code: Select all

<script>
$j('.nav .dropdown-toggle:last').html('YOURLABLEHERE'+$j('.nav .dropdown-toggle:last').html());
</script>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

jrcervantest
Veteran Member
Posts: 32
Joined: 2020-06-22 00:00

Re: Adding Extra Links to NavMenu

Post by jrcervantest » 2020-07-08 19:41

Pböttcher,

Thank you for your assist!

It appears to be working, except it appends the title to the last title as you can see in the enclosed pictures. I will try to play around with it, but if you should come up with an alternate solution, please send it my way. Thank you again!

V/r,
Attachments
1.png
1.png (124.71 KiB) Viewed 2536 times

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Adding Extra Links to NavMenu

Post by pbottcher » 2020-07-09 05:26

Hi,

I'm missing the "empty" group (with no title) in the screenshot.
The script is minimal and assumes you have added the extra nav-link to a non-existing group as you described in the use case.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

hernan
Posts: 26
Joined: 2020-06-22 18:56

Re: Adding Extra Links to NavMenu

Post by hernan » 2020-07-09 12:00

Hi,
You could play with incCommon.php (be aware that everytime you regenerate code you need to avoid replacing this file if you modify it).

To add your custom menu like the other navmenus (aligned to the left), look for function NavMenus().
You need to add your html code to the $menu_wrapper variable... something like

Code: Select all

...
$menu_wrapper .= "<li class='dropdown'>
<a href='#' class='dropdown-toggle' data-toggle='dropdown'>MENU HEADER<b class="caret"></b></a>
</li>"

return $menu_wrapper;
}
Also in the NavMenus() I played with adding a new Table Group Name to the array

Code: Select all

$table_group_name
. Just push a new item to the array:

Code: Select all

$table_group_name = array_keys(get_table_groups()); /* 0 => group1, 1 => group2 .. */
array_push($table_group_name, "Custom Menu Title")
...
, I don't remember exactly why I finally didn't use this for my case... but I remember that I was able to show the menu, only if it's not empty. There's a script in common.js.php that delete the empty menu groups.

You could also add it to the "right", adding it to the HtmlUserBar() function.
Right after (visible in desktop mode)

Code: Select all

<ul class="nav navbar-nav navbar-right hidden-xs">
and after (visible in collapsed navbar)

Code: Select all

<ul class="nav navbar-nav visible-xs">
This will show to the left of the "Logged in as".
right_menu.png
right_menu.png (9.12 KiB) Viewed 2501 times
I hope this gives you a hint on how you could solve your problem.

Saludos,
Hernan.

jrcervantest
Veteran Member
Posts: 32
Joined: 2020-06-22 00:00

Re: Adding Extra Links to NavMenu

Post by jrcervantest » 2020-07-09 18:20

pböttcher and Hernan,

Thank you very much for your feedback. I didn't get any alerts from my email about post replies, so sorry about the delayed response.
I will definitely give your recommendations a try using a careful and methodical approach. I will let you know how it turns out. Thank you again for your support!

V/r,

Post Reply