Nav bar, links

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
eremmen
Posts: 2
Joined: 2020-02-19 15:53

Nav bar, links

Post by eremmen » 2020-02-24 15:04

Dear Community Forum,

thanks for a lot of helpful tips and tricks, what a rewarding place to be! A novice user myself, and so great to learn from other's experiences.

We would like to have the links as seen on the image here, also on the index page. How can I do this? I hope this has not been posted before, I could not find it when I looked.

Have a great week!

E :)
indexphp.PNG
Home/index page
indexphp.PNG (122.44 KiB) Viewed 7105 times
Attachments
itemphp.PNG
table view
itemphp.PNG (50.1 KiB) Viewed 7105 times

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Nav bar, links

Post by jsetzer » 2020-02-24 16:00

Dear Else and Torulf,

you can change this default behaviour in incCommon.php. Find the function htmlUserBar(). There are the following lines:

Code: Select all

<ul class="nav navbar-nav">
  <?php if(!$home_page) { ?>
    <?php echo NavMenus(); ?>
  <?php } ?>
</ul>
You can change or remove the whole if { }-clause and only keep the echo NavMenus(); line.
Code_KiXYMYgi9b.png
Code_KiXYMYgi9b.png (32.35 KiB) Viewed 7102 times

Afterwards, the nav-menus will be visible on homepage, too.

thunderbird_wfCgJBmrfA.png
thunderbird_wfCgJBmrfA.png (4.4 KiB) Viewed 7102 times
Caution: On next generation with will be overwritten.

Hope your project is #1 in Norway now!

Best,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

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

Re: Nav bar, links

Post by pbottcher » 2020-02-24 21:55

Hi,

if you do not want to edit the created file from AppGini (which will be overwritten as Jan stated), add the following to the hooks/header-extras.php file

Code: Select all

<?php
$home_page = (basename($_SERVER['PHP_SELF'])=='index.php' ? true : false);
if ($home_page) {
?>
<script>
$j(function()  {
	var x = '<?php echo str_replace("\r\n",'',str_replace("\t",'',NavMenus()));?>';
	$j('.nav.navbar-nav:first').append(x.replace(/\t/g,''));
	})
</script>
<?php
}
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.

eremmen
Posts: 2
Joined: 2020-02-19 15:53

Re: Nav bar, links

Post by eremmen » 2020-02-25 08:27

Thanks guys, for the tip and for the immediate response! It worked a treat. :)

Jan, I wish I could tell you that we are #1 in Norway, but not quite there yet! But we will be ;)

Thanks again, and have fun with your code.

E :)

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Nav bar, links

Post by jsetzer » 2020-02-25 09:28

Hi @pböttcher,

very good idea and a great tip, thank you very much!

One small thing is happening now: On login-page we now get an empty "Jump-to"-dropdown

chrome_ngIZYrnsZk.png
chrome_ngIZYrnsZk.png (9.45 KiB) Viewed 7061 times

I think next to checking if we are on index.php we should also check if signIn parameter is defined or not.

I hope you don't mind if I add a very little piece to your code:

Code: Select all

<?php $is_homepage = (basename($_SERVER['PHP_SELF']) === 'index.php' && !isset($_REQUEST['signIn'])); if ($is_homepage) { ?>
    <script>
        $j(function() {
            var x = '<?php echo str_replace("\r\n", '', str_replace("\t", '', NavMenus())); ?>';
            $j('.nav.navbar-nav:first').append(x.replace(/\t/g, ''));
        })
    </script>
<?php } ?>
Now the menu's should not be visible on login page...

chrome_oaXmrByXIv.png
chrome_oaXmrByXIv.png (10.16 KiB) Viewed 7061 times

... but should be visible on dashboard ...

chrome_EFZDx0ctBm.png
chrome_EFZDx0ctBm.png (46.02 KiB) Viewed 7061 times

Best,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

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

Re: Nav bar, links

Post by pbottcher » 2020-02-25 19:04

true :)
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.

federico
Veteran Member
Posts: 74
Joined: 2020-10-29 14:52

Re: Nav bar, links

Post by federico » 2021-06-13 13:57

and how do you clean the index page keeping only the navigation bar?
in header page?

tks

Post Reply