hook for page loading

Wish to see a specific feature/change in future releases? Feel free to post it here, and if it gets enough "likes", we'd definitely include it in future releases!
Post Reply
grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

hook for page loading

Post by grimblefritz » 2016-04-05 02:37

It would be useful to have a hook - call it hooks/page_load.php perhaps? - that would fire at every page load and be passed $html that is the output of header.php. This would give us a chance to munge things in the <head> as well as the <body> preamble.

Hooks, in general, I think are a good thing. The more the merrier!

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

Re: hook for page loading

Post by peebee » 2016-04-05 06:44

I could be wrong and I haven't tried it but I think it might be as simple as adding:

Code: Select all

<?php if(is_file(dirname(__FILE__) . '/hooks/page_load.php')){ include(dirname(__FILE__).'/hooks/page_load.php'); } ?>
just above the closing </head> tag of your existing generated header.php

and then adding your new page_load.php to the hooks folder.

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: hook for page loading

Post by grimblefritz » 2016-04-05 11:42

No, that would process 'page_load' WHILE header.php executes and AFTER the existing <head> has been created. Great for adding to the head (but not the body) and not good for modifying the default content.

What I want is a hook so header.php executes and its output is captured into $html and THEN the page_load hook is called and passed $html. Similar to how tablename_dv etc work. This would allow any part of the header to be modified, making it possible via a persistent hook to do things like change the favicon, add meta tags, etc.

Of course, the alternative is to alter the generator and provide a way to set the favicon and to pass additional tags in <head>. Easier for the average user; however, hooks are more flexible for developers. If every possibility were accounted for in the generator, it would become a much more complex tool, both to code and to use.

Post Reply