Announcement

Collapse
No announcement yet.

how to include PHP in temaplates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Forum] how to include PHP in temaplates

    hi all, i have some problem, i need to include an external php file in my template (called Justwhite)

    i've create this plugin

    ob_start();
    include('inclusion/inclusion.php');
    $includedphp = ob_get_contents();
    ob_end_clean();
    vB_Template:reRegister('ad_global_below_navbar',array('includedphp ' => $includedphp));


    but i get an error……


    why?
    Justoverclock.com

  • #2
    What error do you get? Which template are you trying add this to?
    Vote for:

    - *Admin Settable Paid Subscription Reminder Timeframe*
    -
    *PM - Add ability to reply to originator only*
    - Add Admin ability to auto-subscribe users to specific channel(s)
    - "Quick Route" Interface...

    Comment


    • #3
      the template name is called ad_global_below_navbar

      i get an error

      Fatal error: Call to a member function query_first_slave() on a non-object in /forum/includes/class_bootstrap.php on line 894
      Justoverclock.com

      Comment


      • #4
        anyone can help me? there's no way to include this simple php???
        Justoverclock.com

        Comment


        • #5
          Try wrapping your code within this tag:

          <vb:literal>
          Your code here
          </vb:literal>


          If that does not work then you will need to try asking for help with this at the vB mod site: www.vbulletin.org
          Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
          Change CKEditor Colors to Match Style (for 4.1.4 and above)

          Steve Machol Photography


          Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


          Comment


          • #6
            error:


            Parse error: syntax error, unexpected '<' in /home/marko85/domains/justoverclock.com/public_html/forum/global.php(29) : eval()'d code on line 38
            Justoverclock.com

            Comment


            • #7
              Exactly what are you putting in a plugin and which hook location are you using? And exactly what are you putting in a template and which template are you putting it in. Please use the code/html tags.

              Please don't PM or VM me for support - I only help out in the threads.
              vBulletin Manual & vBulletin 4.0 Code Documentation (API)
              Want help modifying your vbulletin forum? Head on over to vbulletin.org
              If I post CSS and you don't know where it goes, throw it into the additional.css template.

              W3Schools &lt;- awesome site for html/css help

              Comment


              • #8
                ok....

                here the plugin code:
                HTML Code:
                ob_start();
                  include('inclusion/inclusion.php');
                  $includedphp = ob_get_contents();
                  ob_end_clean();
                vB_Template::preRegister('ad_global_below_navbar',array('includedphp ' => $includedphp));
                used hook:
                GLOBAL START

                i want to include this:

                http://forum.justoverclock.com/inclusion/inclusion.php

                is an include from wordpress post (mysql)

                i want to include this code in the template:

                ad_global_below_navbar
                Justoverclock.com

                Comment


                • #9
                  From reading the error, it sounds like the problem is something in your php file. Also, you realize global_start is deprecated? And are you sure the path to the file is correct?

                  You really should be posting for help with this over on vbulletin.org, the modification site. There have been several threads about this before over there.

                  Please don't PM or VM me for support - I only help out in the threads.
                  vBulletin Manual & vBulletin 4.0 Code Documentation (API)
                  Want help modifying your vbulletin forum? Head on over to vbulletin.org
                  If I post CSS and you don't know where it goes, throw it into the additional.css template.

                  W3Schools &lt;- awesome site for html/css help

                  Comment


                  • #10
                    i have a thread in vbulletin.org without answer

                    the file are in the "FORUM/inclusion" folder

                    here the inclusion.php

                    HTML Code:
                    <?
                    require("inclusion.config.php");
                    
                    $connessione=mysql_connect($db_server, $db_username, $db_passwd);
                    $db = mysql_select_db($db_name, $connessione);
                    ?>
                    <link rel="stylesheet" type="text/css" href="inclusion.css">
                    <table width="100%" cellpadding="0" cellspacing="0" class="inc_tbl1">
                        <tr>   
                            <td style="width:40%" valign="top" align="center" class="inc_tbl1_title">
                                <?=$inc_title1?>
                            </td>
                            <td style="width:30%" valign="top" align="center" class="inc_tbl1_title">  
                                <?=$inc_title2?>
                            </td>
                            <td style="width:30%" valign="top" align="center" class="inc_tbl1_title">
                                <?=$inc_title3?>
                            </td>
                        </tr>
                        <tr>
                            <td style="width:<?=$wCol1?>" valign="top">
                                <table width="100%" cellpadding="0" cellspacing="0">
                                    <tr>
                                    <?
                                    unset($noId);
                                    $qLastArticle = mysql_query("SELECT ID, post_content, post_title, guid FROM $tbl_post_wp  WHERE post_status = 'publish' AND post_parent = '0' ORDER BY post_date DESC LIMIT $n_last_article");  
                                    while($rLastArticle = mysql_fetch_assoc($qLastArticle)){
                                        
                                        $noId .= " AND id!= '$rLastArticle[ID]' ";
                    
                                        $qLastArticleImg = mysql_query("SELECT guid FROM $tbl_post_wp  WHERE post_mime_type LIKE 'image/%' AND post_parent = '$rLastArticle[ID]' ORDER BY post_date ASC LIMIT 1");  
                                        $rLastArticleImg = mysql_fetch_assoc($qLastArticleImg);
                                    ?>
                                        <td style="padding:2px">
                                            <a href="<?=$rLastArticle[guid]?>"><b><?=$rLastArticle[post_title]?></b></a>
                                            <div style="clear:both;height:5px"></div>
                                            <div id="LastArticle">
                                            <?
                                            if($rLastArticleImg[guid] != ""){
                                            ?>
                                            <div id="imgLastArticle">
                                                <img src="<?=$base?>phpThumb/phpThumb.php?src=<?=$rLastArticleImg[guid]?>&w=<?=$img_width?>&h=<?=$img_height?>&q=100">
                                            </div>
                                            <?                        
                                            }
                                            ?>   
                                        
                                                <?=substr(strip_tags($rLastArticle[post_content]),0,$lengthLastArticle)?>...
                                            </div>
                                        </td>
                                    <?
                                    }
                                    ?>
                                    </tr>
                                </table>
                            </td>
                            <td style="width:<?=$wCol2?>" valign="top">
                                <table width="100%" cellpadding="0" cellspacing="0" class="inc_tbl2">
                            <?
                            $qTenArticle = mysql_query("SELECT ID, post_title, guid FROM $tbl_post_wp  WHERE post_status = 'publish' AND post_parent = '0' $noId ORDER BY post_date DESC LIMIT 10");  
                            while($rTenArticle = mysql_fetch_assoc($qTenArticle)){
                                ?>
                                    <tr>
                                        <td><a href="<?=$rTenArticle[guid]?>"><b><?=$rTenArticle[post_title]?></b></a></td>
                                    </tr>
                                <?    
                            }
                            ?>
                                </table>
                            </td>
                            <td style="width:<?=$wCol3?>" valign="top">3</td>
                        </tr>
                    </table>
                    here my inclusion-config.php

                    HTML Code:
                    <?
                    $db_server = "localhost";
                    $db_username = "xxxxxx";
                    $db_passwd = "xxxxxx";
                    $db_name = "xxxx";
                    $tbl_post_wp = "xxxx";
                    $lengthLastArticle = 300;
                    $img_width = "100";
                    $img_height = "100";
                    $n_last_article = 2;
                    $wCol1 = "40%";
                    $wCol2 = "30%";
                    $wCol3 = "30%";
                    $inc_title1 = "Ultime 2 news";
                    $inc_title2 = "Ultime 10 news";
                    $inc_title3 = "xxxxxxx";
                    ?>

                    i don't know if the hook is correct

                    i want to see this inclusion under the navbar (above adsense) in this site

                    http://forum.justoverclock.com - make sure you set the skin JUSTWHITE
                    Justoverclock.com

                    Comment


                    • #11
                      I think the problem is, that $db allready exists from vB and your code is overwriting it.

                      Try to use
                      PHP Code:
                      $databasevB $db;
                      // your code
                      $db $databasevB
                      Maybe this could work!

                      Comment


                      • #12
                        ok i think is that the way!!!!!!

                        now i'm not have any error, but if i put the code

                        Code:
                        {vb:raw $includedphp}

                        nothing appear…..why?


                        hear my plugin:

                        HTML Code:
                        ob_start();
                          include('inclusion/inclusion.php');
                          $includedphp = ob_get_contents();
                          ob_end_clean();
                        vB_Template::preRegister('ad_global_below_navbar',array('includedphp ' => $includedphp));
                        Justoverclock.com

                        Comment


                        • #13
                          {vb:raw includedphp} and not {vb:raw $includedphp}

                          Comment


                          • #14
                            nothing appear :O
                            Justoverclock.com

                            Comment


                            • #15
                              is impossible, i put the code
                              HTML Code:
                              {vb:raw includedphp}
                              in many template....

                              but nothing appear!

                              justoverclock.com/forum/inclusion/inclusion.php (works!)
                              hook is set to global start.....

                              what can i do now?
                              Justoverclock.com

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X