• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Creating my first ever addon

xpl0iter

Active member
#1
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:


This is my Code Event Listener Configuration:


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

Thanks.
 

Chris D

XenForo developer
Staff member
#2
This line:

if($hookname == 'ad_above_top_breadcrumb')

Should be:

if($hookName == 'ad_above_top_breadcrumb')

You have to be pedantic about case sensitivity!
 

xpl0iter

Active member
#3
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
 

Chris D

XenForo developer
Staff member
#4
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.
 
R

ragtek

Guest
#5
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.jpg
 

Chris D

XenForo developer
Staff member
#6

MOZ

Well-known member
#7
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)
 

Chris D

XenForo developer
Staff member
#9
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.