owner Posted September 3, 2009 Report Share Posted September 3, 2009 First, sorry to ask so many questions, I feel like I am spamming the site :( I am trying to start my first hook, and just for a test, I would like to display something in the footer of my board right before </body> tag. I just don't quite understand the hook_data and hooks_source tags under the hookfiles tag. How do I code to hook to place the code in certain spots. Not sure if this makes sense, if it doesn't let me know, Thanks in advance! -owner Quote Link to comment Share on other sites More sharing options...
Management Michael Posted September 3, 2009 Management Report Share Posted September 3, 2009 No problem, we all gotta start somewhere ;) First you'll need to add a hook in the admin cp. Open System Tab > Manage Hooks > Create New Hook. Where it says Hook Files click the Add New File button. File name in hooks directory: yourhookfilename.php This file's class name: yourhookfilename This file's hook type: Template Hook: The skin group this hook is in: skin_global The skin function this hook is in: globalTemplate Type of template hook: if statement The hook 'id': mainpageContent Type of template hook: post.endif There is no place to hook exactly above closing body tag, so I've chosen mainpageContent instead. Now save that hook file. And add a file called yourhookfilename.php to your hooks folder. Your hook file will look something like this <?php class yourhookfilename { public $registry; public function __construct() { $this->registry = ipsRegistry::instance(); } public function getOutput() { return "test"; } } ?> Then as long as your in IN_DEV mode, you'll be able to export that hook file. We name the file as yourhookfilename.php during development but during import of the hook IPB3 adds _######## random numbers after the hook name. Quote Link to comment Share on other sites More sharing options...
owner Posted September 4, 2009 Author Report Share Posted September 4, 2009 Ok I got it working, but for some reason I cant see it saying test on the page or in the source code of the page. If I use echo "test"; I can see it displayed at the top of my page though. Do I need to use something special to output it? Quote Link to comment Share on other sites More sharing options...
Management Michael Posted September 5, 2009 Management Report Share Posted September 5, 2009 Try going to the template bit your hooking into and Save the template bit. Don't have to make any changes. Quote Link to comment Share on other sites More sharing options...
owner Posted September 5, 2009 Author Report Share Posted September 5, 2009 Nothing. I think it is the php file that is wrong. Should I be using something else than return? Quote Link to comment Share on other sites More sharing options...
Management Michael Posted September 5, 2009 Management Report Share Posted September 5, 2009 So this is a template hook? No return is the one. Mind sending me the hook file so can see what's wrong? Quote Link to comment Share on other sites More sharing options...
owner Posted September 5, 2009 Author Report Share Posted September 5, 2009 Sent you a PM with the hook source attached. Quote Link to comment Share on other sites More sharing options...
Management Michael Posted September 6, 2009 Management Report Share Posted September 6, 2009 Can see the pm but no attachments, noticed you deleted the conversation, maybe that deletes attachments. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.