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
User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
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: 352
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?

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
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

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

Re: hook for index.php / homepage?

Post by pbottcher » 2019-10-08 06:36

Hi,

just check which page is currently loaded and execute your code only when the index page is loaded.
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.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
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

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

Re: hook for index.php / homepage?

Post by pbottcher » 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 
}
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.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
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: 352
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


Post Reply