How to add more than one link to the Array in links-home.php?

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
mohamed
Veteran Member
Posts: 88
Joined: 2020-04-19 16:18

How to add more than one link to the Array in links-home.php?

Post by mohamed » 2020-10-24 08:24

Hello,

I need to add three (3) URLs in the Array in links-home.php :
../budget/Projects_2020.php
../budget/Projects_2021.php
../budget/Projects_2022.php

I am able to add a single link, but I don't How to add the other links!

I have tried to add the 2nd like for instance like this but it did not work:
'url' => '../budget/Projects_2020.php', '../budget/Projects_2021.php',

How to add more than one link to the Array ?



links-home.php
$homeLinks[] = array(
'url' => '../budget/Projects_2020.php',
'title' => 'Project of 2020',
'groups' => array('Users'),
);
THANK YOU...
AppGini Pro 24.11 -
Calendar - Search Page Maker - Summary Reports - Mass Update - DataTalk -
bizzworxx AppGini Helper JabaScript Library - bizzworxx Inline Detail-View - bizzworxx Helper Pack - AppGini Helper Packaging Tool -
Udemy course

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

Re: How to add more than one link to the Array in links-home.php?

Post by jsetzer » 2020-10-24 08:59

Code: Select all

// file: hooks/links-home.php

// #1
$homeLinks[] = array(
'url' => '../budget/Projects_2020.php',
'title' => 'Project of 2020',
'groups' => array('Users'),
);

// #2
$homeLinks[] = array(
'url' => '../budget/Projects_2021.php',
'title' => 'Project of 2021',
'groups' => array('Users'),
);

// ... repeat for every new home-link
$homeLinks[] = array(
'url' => '../budget/Projects_yyyy.php',
'title' => 'Project of yyyy',
'groups' => array('Users'),
);
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 25.10 + all AppGini Helper tools

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

Re: How to add more than one link to the Array in links-home.php?

Post by jsetzer » 2020-10-24 09:04

If you have named all custom pages after the same pattern:

Code: Select all

$min = 2020;
$max = 2022;
for ($y = $min; $y <= $max; $y++) {
  $homeLinks[] = array(
    'url' => "../budget/Projects_{$y}.php",
    'title' => 'Project of {$y}',
    'groups' => array('Users'),
    // more settings
  );
} // end for
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 25.10 + all AppGini Helper tools

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

Re: How to add more than one link to the Array in links-home.php?

Post by jsetzer » 2020-10-24 09:09

Instead of writing one script per year, you could also use the same script and pass the year as parameter:

Code: Select all

$min = 2020; // from starting year 2020...
$max = date("Y"); // until current year (including)

for ($y = $min; $y <= $max; $y++) {
  $homeLinks[] = array(
    'url' => "../budget/Projects_report.php?y={$y}",
    'title' => 'Projects of {$y}',
    'groups' => array('Users'),
    // more settings
  );
} // end for
In your report-script, fetch the year from URL:

Code: Select all

$y = isset($_REQUEST['y']) ? makeSafe($_REQUEST['y']) : date('Y');
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 25.10 + all AppGini Helper tools

mohamed
Veteran Member
Posts: 88
Joined: 2020-04-19 16:18

Re: How to add more than one link to the Array in links-home.php?

Post by mohamed » 2020-10-24 10:05

Hello jsetzer,

Simply, you are a lifesaver ;)
and
many thanks for your generosity in sharing the code.


Have a nice day
THANK YOU...
AppGini Pro 24.11 -
Calendar - Search Page Maker - Summary Reports - Mass Update - DataTalk -
bizzworxx AppGini Helper JabaScript Library - bizzworxx Inline Detail-View - bizzworxx Helper Pack - AppGini Helper Packaging Tool -
Udemy course

Post Reply