hook for index.php / homepage?

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 298
Joined: 2019-05-21 22:42
Contact:

hook for index.php / homepage?

Post by onoehring » 2019-10-05 10:35

Hi,

I am using JS to set specific names for some windows of my application using

Code: Select all

window.name = 'myWindowName';
This works fine in regular tables, but how can I do this on the homepage (index.php)?
I place this code in the /hooks/filename-tv.js file.

Why?
I open some links in these specific windows (reusing tabs like I need to) using this HTML

Code: Select all

<a href="somePage" target="myWindowName">blabla</a>
Olaf

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 213
Joined: 2013-03-21 04:37

Re: hook for index.php / homepage?

Post by peebee » 2019-10-08 04:14

/hooks/footer-extras.php is loaded with every page including your homepage. You could call your javascript file from there?

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 298
Joined: 2019-05-21 22:42
Contact:

Re: hook for index.php / homepage?

Post by onoehring » 2019-10-08 06:27

Hi peebee,

good idea, but I believe in this case it will not work: As you said: footer will be loaded in every page and thus every page will get the title I set there.

Olaf

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 608
Joined: 2018-04-01 10:12

Re: hook for index.php / homepage?

Post by pböttcher » 2019-10-08 06:36

Hi,

just check which page is currently loaded and execute your code only when the index page is loaded.

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 298
Joined: 2019-05-21 22:42
Contact:

Re: hook for index.php / homepage?

Post by onoehring » 2019-10-09 05:20

Hi pbötcher,

someting like peebees idea:
dirty code:
if window.name<>'something' { window.name = 'something'}

Or do you see any other method to check which page is loaded? Maybe phpself and only provide the JS that is needed?

Olaf

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 608
Joined: 2018-04-01 10:12

Re: hook for index.php / homepage?

Post by pböttcher » 2019-10-09 18:44

Hi,

almost,

I used some time ago this. You may try it. Or possibly use the new function of 5.8 (which I did not test)

Code: Select all

<?php
$filename=basename($_SERVER['SCRIPT_FILENAME']);
$tablename=substr($filename,0,-4);
// exclude the login page 
if ($tablename == "index" && isset($_SESSION['memberID']) &&  $_SESSION['memberID'] != 'guest') {
?>
<script>
DO WHAT YOU NEED HERE
</script>
<?php 
}

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 298
Joined: 2019-05-21 22:42
Contact:

Re: hook for index.php / homepage?

Post by onoehring » 2019-10-10 04:46

Hi pbötcher,

nice code. I will try and report back.
Thank you
Olaf

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 213
Joined: 2013-03-21 04:37

Re: hook for index.php / homepage?

Post by peebee » 2019-10-10 07:03

You could also view one of Ahmad's handy video tutorials which will show you how to select the desired page via php and include your javascript.

https://www.youtube.com/watch?v=hBkvdWh-OEw

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 298
Joined: 2019-05-21 22:42
Contact:

Re: hook for index.php / homepage?

Post by onoehring » 2019-10-10 12:16

Hi peebee,

good idea. Thank you.
Olaf

Post Reply