Creating my first ever addon

xpl0iter

Active member
I am trying to create my first ever addon. I need some help.
Here I am going to explain all the stuffs I have done till so far.

Folder Structure:
Library
---WGBB
------dailyCount
-----------Listener.php

Contents of Listener.php
Code:
<?php
 
class WGBB_dailyCount_Listener
{
public static function template_hook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
{
if($hookname == 'ad_above_top_breadcrumb')
{
$contents .= '<li><a href="http://www.webgurubb.com">Our Tab</a></li>';
}
}
}
 
?>

This is my Addon Configuration:
Jzqp0.png


This is my Code Event Listener Configuration:
ywpVH.png


But this simply is not working, is there anything that I am doing wrong?
Anyhelp will be very much appreciated!

Thanks.
 
This line:

if($hookname == 'ad_above_top_breadcrumb')

Should be:

if($hookName == 'ad_above_top_breadcrumb')

You have to be pedantic about case sensitivity!
 
This line:

if($hookname == 'ad_above_top_breadcrumb')

Should be:

if($hookName == 'ad_above_top_breadcrumb')

You have to be pedantic about case sensitivity!
Wt* seriously, this just wasted almost 10 hours of mine!
Thanks mate, thanks you sooo much for pointing it out! :D
 
We've all been there (y)

At first glance I couldn't see anything wrong with your code at all, so I just knew it would be something minute like that - and it was.

Good luck with the add-on.
 
Are you using an IDE?

I would really suggest to use one (netbeans, phpstorm,zend studio,whatever.......)

They'll show/highlight you all the (stupid) code mistakes, which are happening to all of us^^ (it won't even happen because of Autocompletion^^)

e.g here's one undefined and one unused variable (gray variable name and red underwaved)
ide.webp
 
Wt* seriously, this just wasted almost 10 hours of mine!
Thanks mate, thanks you sooo much for pointing it out! :D
As Chris said we've all been there. I wasted 2 days with an issue which was with a the way my editor was encoding the file on my PC, code was fine and so was everything. Happens to all of us (y)
 
I need to be good with AJAX stuff for something I'm working on at the moment :p

And I've done tiny little customisations pertaining to AJAX for example the Quick Reply preview add-on and a little bit in my Notifications add-on.

Learning way more about Javascript than I ever thought I would!

And no, never done anything with WordPress.
 
Top Bottom