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

PHP in sidebar?

Discussion in 'XenForo Development Discussions' started by Wuebit, Feb 22, 2011.

  1. Wuebit

    Wuebit Well-Known Member

    Hey i have some php code i need to add to the sidebar

    So my question is how can i add php to a template and make it work
    I was planing on following this

    Thank's
     
  2. Floris

    Floris Guest

    You put the .php in your php file within the framework, populate it to a variable or point it to custom template, and include either the variable or the custom template in the sidebar.

    The screenshot is just an untested quick dirty draft to give the impression of what possibly needs to be done. Depending on what YOU need from you plugin, this might be of help to get started.
     

    Attached Files:

    Vodkaholic likes this.
  3. Wuebit

    Wuebit Well-Known Member

    Thank's Floris sadly my php skill's are bad ;/ fancy giving me an example <3
    Cheer's
     
  4. Floris

    Floris Guest

    Eh, there are add-ons you can use as example perhaps. I am a horrible coder myself.
    I've attached files to my post now.
     
    Vodkaholic likes this.
  5. Wuebit

    Wuebit Well-Known Member

    Oh i mean the way you called it from the php file (in the template)
    Or would i have to mod my php file to work?

    Cheer's
     
  6. Floris

    Floris Guest

    {$yourSidebar} in page_container before </sidebar> or </xen:sidebar> (dont recall by memory which one it is)
     
  7. Wuebit

    Wuebit Well-Known Member

    Hmm ok am lost lol
    so template is this

    Code:
    <div class="section">
        <div class="secondaryContent">
    <h3>Test</h3>
    {$images_booru}
        </div>
    </div>
    adding this before <xen:include template="test" /> will show what's in my php file in the side bar?

    It's the {$images_booru} part i don't understand

     
  8. Floris

    Floris Guest

    You're not getting it, but it's complex to just explain in 1 phrase. I recommend to use an existing example and compare it against the videos by kier in the have you seen.. and official developer threads... forums.
     
  9. Wuebit

    Wuebit Well-Known Member

    Yea i have seen the video's you are on about but that's for a custom page

    all i am trying to do is add

    PHP:
    $output '';
    $cdb = new PDO('mysql:dbname=xxxxxxxxxxx;host=localhost''xxxxxxxxxxxxx''xxxxxxxxxxxxxx');
    $res $cdb->query("SELECT COUNT(*) AS imgtotal FROM images");
    $ct $res->fetch(PDO::FETCH_ASSOC);
    for (
    $x 0$x strlen($ct['imgtotal']); $x++) $output .= ' <img alt="' $ct['imgtotal'][$x] . '" src=" /imageboard/ext/home/counters/default/' $ct['imgtotal'][$x] . '.gif" width="40" height="80"/>';
    return 
    $output;
    this into a sidebar ;/ oh well thank's anyway Floris
     
  10. Dean

    Dean Well-Known Member

    moving to development questions forum as requested..
     
  11. Brett Peters

    Brett Peters Well-Known Member

    Use widget framework add-on, put the php code into a .php file, then in widget framework html add something like the following

    Code:
    <center>
    <iframe marginwidth="0" marginheight="0" width="40" height="80" scrolling="no" frameborder=0 src="******.php">
    </iframe>
    </center>
    Just a thought
     
    ProCom and Wuebit like this.
  12. Wuebit

    Wuebit Well-Known Member

    Rofl i never thought of an Iframe thank's muchy
     
  13. ProCom

    ProCom Active Member

    Just gotta bring this back up to say that it worked PERFECTLY for a big part of our site. We do a weekly favorite picture (pic of the week) and I called our PHP file using iframes just as posted above and it worked in the widget plugin absolutely perfectly!!!
     

Share This Page