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

Creating an addon and a weird thing happens! Help!

Discussion in 'XenForo Development Discussions' started by Matthew Hawley, Jun 20, 2013.

  1. Matthew Hawley

    Matthew Hawley Well-Known Member

    Okay lets see what I'm doing.

    So this the Listener.php

    Code:
    <?php
    
    class MumbleViewer_Listener
    {
        public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
        {
            if ($hookName == 'ad_sidebar_bottom')
            {
                $contents .= $template->create('mumble_viewer_sidebar', $template->getParams());
            }
        }
    }
    This is the template mumble_viewer_sidebar:

    Code:
    <div class="section">
        <div class="secondaryContent">
            <h3>{xen:phrase mumble_viewer_sidebar_title}</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>
    And this is what I put into the form for creating a Code Event Listener

    addonhelp.png

    Now when I save everything shows up like its supposed to, except this happens. (You may have to look closely, theres a gray space above the moderator bar.

    addonproblem.png

    When I put "templateHook" into the Event Hint the problem in the image above goes way, but the template that goes in "ad_sidebar_bottom goes away aswell. I suspect there might be a new way of doing this in 1.2 or something. Anyone know the problem?

    Thanks in advance!
     
  2. xf_phantom

    xf_phantom Well-Known Member

    the event hint for the templatehook is the hookname (did your read the description text? :D )

    In your case => ad_sidebar_bottom
     
  3. Matthew Hawley

    Matthew Hawley Well-Known Member

    Okay, so I put ad_sidebar_bottom in the Event Hint and the same thing happens.
     
  4. Matthew Hawley

    Matthew Hawley Well-Known Member

  5. James

    James Well-Known Member

    That grey bar looks like a suppressed error. Check your source code?
     
  6. Russ

    Russ Well-Known Member

    I think giving more than 15 minutes for a response would be good haha :D
     
    SneakyDave likes this.
  7. Matthew Hawley

    Matthew Hawley Well-Known Member

    Yeah lol...sorry. Sometimes I'm not a patient guy. When I have an error thats really frustrating me, I want it fixed fast...
     
  8. Matthew Hawley

    Matthew Hawley Well-Known Member

    So I used inspect element and I noticed this:

    When I unchecked it the grey bar at the top became longer horizontally.
     
  9. Matthew Hawley

    Matthew Hawley Well-Known Member

    Okay so the font size is the issue. I changed 13px to 0 and it went away. Though I don't know what's producing this.
     
  10. Matthew Hawley

    Matthew Hawley Well-Known Member

    I also get server errors from the addon im making.

    Server Error Log
    Error Info
    ErrorException: Cannot modify header information - headers already sent by (output started at /home/mcwh/public_html/letspwn.com/store/library/MumbleViewer/Listener.php:1) - library/XenForo/CssOutput.php:558
    Generated By: Unknown Account, Today at 2:32 PM
    Stack Trace
    #0 [internal function]: XenForo_Application::handlePhpError(2, 'Cannot modify h...', '/home/mcwh/publ...', 558, Array)
    #1 /home/mcwh/public_html/letspwn.com/store/library/XenForo/CssOutput.php(558): header('Content-type: t...')
    #2 /home/mcwh/public_html/letspwn.com/store/library/XenForo/CssOutput.php(590): XenForo_CssOutput->displayCss('@CHARSET "UTF-8...')
    #3 /home/mcwh/public_html/letspwn.com/store/css.php(12): XenForo_CssOutput::run()
    #4 {main}
    Request State
    array(3) {
    ["url"] => string(86) "http://letspwn.com/store/css.php?css=xenforo,form,public&style=15&dir=LTR&d=1371731639"
    ["_GET"] => array(4) {
    ["css"] => string(19) "xenforo,form,public"
    ["style"] => string(2) "15"
    ["dir"] => string(3) "LTR"
    ["d"] => string(10) "1371731639"
    }
    ["_POST"] => array(0) {
    }
    }
     
  11. SneakyDave

    SneakyDave Well-Known Member

    Normally that error means you are echoing/printing something from PHP file Listener.php, or you have some additional white space after the ?> at the end of the file, but I would suspect xF takes care of that(?)

    Do you need the ?> at the end of the listener?
     
  12. Matthew Hawley

    Matthew Hawley Well-Known Member

    I don't think so.

    This is the Listener.php

    Code:
    <?php
    
    class MumbleViewer_Listener
    {
        public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
        {
            if ($hookName == 'ad_sidebar_bottom')
            {
                $contents .= $template->create('mumble_viewer_sidebar', $template->getParams());
            }
        }
    }
     
  13. SneakyDave

    SneakyDave Well-Known Member

    Yeah, you don't need the ?> at the end. Do you have display_errors on in your config? Maybe there's a a notice or something being displayed?
     
  14. Matthew Hawley

    Matthew Hawley Well-Known Member

    I don't have ?> at the end.

    No. I have

     
  15. SneakyDave

    SneakyDave Well-Known Member

    I don't know if it will help, but you can try adding this to your config.php temporarily to see if there is a notice or something, but it appears to me something it being sent as output before the headers can be set.

    Code:
    ini_set('display_errors', true);
    
     
  16. Matthew Hawley

    Matthew Hawley Well-Known Member

    Added it. Where do the errors show up?
     
  17. Matthew Hawley

    Matthew Hawley Well-Known Member

    @SneakyDave Could you install this on a test forum or something and see if the grey bar at the top shows up?

    Thanks.
     

    Attached Files:

  18. Matthew Hawley

    Matthew Hawley Well-Known Member

  19. SneakyDave

    SneakyDave Well-Known Member

    I tried it on my 1.1.4 test installation. It completely screwed up the default xf style, but I got the game tracker IFRAME to show up.

    matthews_mumble.png
     
  20. Matthew Hawley

    Matthew Hawley Well-Known Member

    Why would it screw it up...I doesn't screw up mine.
     

Share This Page