Page 1 of 1
hook for page loading
Posted: 2016-04-05 02:37
by grimblefritz
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!
Re: hook for page loading
Posted: 2016-04-05 06:44
by peebee
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.
Re: hook for page loading
Posted: 2016-04-05 11:42
by grimblefritz
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.