Creating an addon and a weird thing happens! Help!

It's not the iframe, and it's not your template. If you remove the contents of your entire template, the error still happens.
 
hm, working nice for me with the template code from
http://xenforo.com/community/threads/creating-an-addon-and-a-weird-thing-happens-help.53005/


PHP:
<?php

class Test_Listener{

    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template){
        if ($hookName == 'ad_sidebar_bottom'){
            $contents .= self::getTemplateCode();
        }
    }


    public static function getTemplateCode(){
$code = <<<C
<div class="section">
    <div class="secondaryContent">
        <h3>test</h3>
                      <iframe src="http://cache.www.gametracker.com/components/html0/?host=193.218.154.228:64738&bgColor=1F2642&fontColor=8790AE&titleBgColor=11172D&titleColor=FFFFFF&borderColor=333333&linkColor=FF9900&borderLinkColor=999999&showMap=0&currentPlayersHeight=160&showCurrPlayers=1&showTopPlayers=0&showBlogs=0&width=240" frameborder="0" scrolling="no" width="240" height="348"></iframe>
    </div>
</div>
C;

        return $code;
    }
}
 

Attachments

  • sidebardemo.webp
    sidebardemo.webp
    16.7 KB · Views: 9
  • code event listener.webp
    code event listener.webp
    55.6 KB · Views: 9
One problem is that $contents in your listener.php file should be $content. ;)

Ooops, sorry, I was looking at one of my listeners, ignore that.
 
hm, working nice for me with the template code from
http://xenforo.com/community/threads/creating-an-addon-and-a-weird-thing-happens-help.53005/


PHP:
<?php

class Test_Listener{

    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template){
        if ($hookName == 'ad_sidebar_bottom'){
            $contents .= self::getTemplateCode();
        }
    }


    public static function getTemplateCode(){
$code = <<<C
<div class="section">
    <div class="secondaryContent">
        <h3>test</h3>
                      <iframe src="http://cache.www.gametracker.com/components/html0/?host=193.218.154.228:64738&bgColor=1F2642&fontColor=8790AE&titleBgColor=11172D&titleColor=FFFFFF&borderColor=333333&linkColor=FF9900&borderLinkColor=999999&showMap=0&currentPlayersHeight=160&showCurrPlayers=1&showTopPlayers=0&showBlogs=0&width=240" frameborder="0" scrolling="no" width="240" height="348"></iframe>
    </div>
</div>
C;

        return $code;
    }
}

The sidebar isn't the problem. The problem is that theres a gray bar showing above the moderator bar
 
There's something wrong with the Listener file itself, maybe the encoding or something, I created a new Listener.php file with the same contents and it worked.
 
The code is changed just a bit (using a switch/case statement), but I think if you ditch that original Listener.php file, and create a new one, it'll work.

Code:
<?php

class MumbleViewer_Listener {
    public static function templateHook($hookName, &$content, array $hookParams, Xenforo_Template_Abstract $template)
    {
        switch($hookName){
            case 'ad_sidebar_bottom';
                $content .= $template->create('mumble_viewer_sidebar', $template->getParams());
            break;
        }
    }
}

matthews_mumble2.webp
 
hm, working nice for me with the template code from
http://xenforo.com/community/threads/creating-an-addon-and-a-weird-thing-happens-help.53005/


PHP:
<?php

class Test_Listener{

    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template){
        if ($hookName == 'ad_sidebar_bottom'){
            $contents .= self::getTemplateCode();
        }
    }


    public static function getTemplateCode(){
$code = <<<C
<div class="section">
    <div class="secondaryContent">
        <h3>test</h3>
                      <iframe src="http://cache.www.gametracker.com/components/html0/?host=193.218.154.228:64738&bgColor=1F2642&fontColor=8790AE&titleBgColor=11172D&titleColor=FFFFFF&borderColor=333333&linkColor=FF9900&borderLinkColor=999999&showMap=0&currentPlayersHeight=160&showCurrPlayers=1&showTopPlayers=0&showBlogs=0&width=240" frameborder="0" scrolling="no" width="240" height="348"></iframe>
    </div>
</div>
C;

        return $code;
    }
}

I tried this Listener.php. I deleted and created a new Code Event Listener and I got this error.

The server responded with an error. The error message is in the JavaScript console.
 
The code is changed just a bit (using a case statement), but I think if you ditch that original Listener.php file, and create a new one, it'll work.

Code:
<?php

class MumbleViewer_Listener {
    public static function templateHook($hookName, &$content, array $hookParams, Xenforo_Template_Abstract $template)
    {
        switch($hookName){
            case 'ad_sidebar_bottom';
                $content .= $template->create('mumble_viewer_sidebar', $template->getParams());
            break;
        }
    }
}

View attachment 49458

Okay I'll try this.
 
The code is changed just a bit (using a case statement), but I think if you ditch that original Listener.php file, and create a new one, it'll work.

Code:
<?php

class MumbleViewer_Listener {
    public static function templateHook($hookName, &$content, array $hookParams, Xenforo_Template_Abstract $template)
    {
        switch($hookName){
            case 'ad_sidebar_bottom';
                $content .= $template->create('mumble_viewer_sidebar', $template->getParams());
            break;
        }
    }
}

View attachment 49458

This and my original one both do the same thing. The template showing up in the sidebar IS NOT the problem. The problem is the gray bar showing up above the moderator bar.

addonproblem.webp
 
I don't have a grey bar showing at the top, and I don't have a "Output already sent" error message.

Did you delete that Listener.php file and create a new one? Do you still get the "Output already sent" error message?

Did you turn off your other add-ons?
 
Delete it completely, create a new one. That's what I did, and it worked.

The error message says that the output is being generated by that file starting at line one, but I can't tell why that would be. I think the file is somehow corrupted.
 
Delete it completely, create a new one. That's what I did, and it worked.

The error message says that the output is being generated by that file starting at line one, but I can't tell why that would be. I think the file is somehow corrupted.

I deleted it and it still shows. Maybe i should refresh my cache.
 
Do you still get the error message? Did you turn off your other add-ons? You need to isolate your test forum so that you're only working with your mumble listener.

This is my local installation for xF 1.1.4. No gray bar at the top, and the mumble add-on partially shown in the sidebar, although game server can't be reached, but that should be an easy fix.

matthews_mumble_3.webp
 
Last edited:
Top Bottom