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!
hook for page loading
Re: hook for page loading
I could be wrong and I haven't tried it but I think it might be as simple as adding:
just above the closing </head> tag of your existing generated header.php
and then adding your new page_load.php to the hooks folder.
Code: Select all
<?php if(is_file(dirname(__FILE__) . '/hooks/page_load.php')){ include(dirname(__FILE__).'/hooks/page_load.php'); } ?>
and then adding your new page_load.php to the hooks folder.
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: hook for page loading
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.
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.