Page 1 of 1

hook for index.php / homepage?

Posted: 2019-10-05 10:35
by onoehring
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

Re: hook for index.php / homepage?

Posted: 2019-10-08 04:14
by peebee
/hooks/footer-extras.php is loaded with every page including your homepage. You could call your javascript file from there?

Re: hook for index.php / homepage?

Posted: 2019-10-08 06:27
by onoehring
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

Re: hook for index.php / homepage?

Posted: 2019-10-08 06:36
by pbottcher
Hi,

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

Re: hook for index.php / homepage?

Posted: 2019-10-09 05:20
by onoehring
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

Re: hook for index.php / homepage?

Posted: 2019-10-09 18:44
by pbottcher
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 
}

Re: hook for index.php / homepage?

Posted: 2019-10-10 04:46
by onoehring
Hi pbötcher,

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

Re: hook for index.php / homepage?

Posted: 2019-10-10 07:03
by peebee
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

Re: hook for index.php / homepage?

Posted: 2019-10-10 12:16
by onoehring
Hi peebee,

good idea. Thank you.
Olaf