Jump to content
DevFuse Forums

Help with first hook


owner

Recommended Posts

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

Link to comment
Share on other sites

  • Management

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...