1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to include file.php on my Vbulletin forum

Discussion in 'PHP' started by Adulu, Aug 15, 2007.

  1. #1
    I would like to include file.php on frontpage.
    http://www.adulu.com/index.php

    Therefore I try to modify and insert code for "footer" templete as below code
    <?php
    include("file.php");
    ?>
    or 
    
    include("file.php");
    or
    include('file.php');
    PHP:
    but web page echo nothing
    I think Vbulletin disable something.

    How can i to do?
     
    Adulu, Aug 15, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Hm, you could try the following.

    Put this in the php file where you want to include the file.
    
    ob_start();
    include 'file.php';
    $include_contents = ob_get_contents();
    ob_end_flush();
    
    PHP:
    Now go to the admin panel, and add this into the appropriate template:
    
    $include_contents
    
    PHP:
    That could work.
     
    nico_swd, Aug 15, 2007 IP
  3. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ob_start();include 'aduluads.php';$include_contents = ob_get_contents();ob_end_flush();
    PHP:
    Should i insert this code which file or template?

    I insert in index.php
    below images currently problem
    [​IMG]
    [​IMG]
    "123" is file contents.

    left top "123" is unnecessary but it is from this code "ob_start();include 'file.php'....."

    right top "123" is from $include_contents where i have written

    left down "123" , I don't know why echo "123"

    please help me.
     
    Adulu, Aug 15, 2007 IP
  4. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I just refresh index got erorr message

    I think i insert code in index.php cause erorr.
     
    Adulu, Aug 15, 2007 IP
  5. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #5
    It will not work that way.

    You will need to put the coding into a plugin (stored in a variable), then you will echo that variable in the footer template.

    But you need to make sure you specify the right place for the plugin (I think it should say something like footer).

    I will tell you how when I get home.

    Peace,
     
    Barti1987, Aug 15, 2007 IP
  6. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #6
    :) I am looking forware to your response.
     
    Adulu, Aug 15, 2007 IP
  7. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #7
    Sorry I am late, I totally forgot about it until I visited my Admin panel.

    1 - Go to admin control panel - plugin manager

    2 - Add a new plugin

    3
    Product - Vbulletin
    Hook Location depends on where you want to display your "code". If you want it at the time the system is parsing the template (eg. header, footer) use: parse_templates as the location.
    Title - enter a title
    Plugin PHP code - something like
    
    global $vbulletin;
    $custom_info = 'Testing123';
    //You can run mysql queries too
    //$is_test = false;
    
    PHP:
    4 - Go to styles and template manager

    5 - Edit common templates

    6 - Place $custom_info where you want "Testing123" to appear.

    You can also do if statments to true/false variables within the template:

    
    <if condition="$is_test">
    Test Passed
    <else />
    Test Not Passed
    </if>
    
    PHP:
    Peace,
     
    Barti1987, Aug 16, 2007 IP
  8. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #8
    [​IMG]
    I succeed in what i expected.

    but I have another question how to replace Testing123 with include("aduluads.php");

    
    $custom_info = 'Testing123';
    
    PHP:
    I have had test below code It won't working fine and got error message
    $custom_info = 'include("aduluads.php");';
    or
    $custom_info = 'include('aduluads.php');';
    or
    $custom_info = 'include(aduluads.php);';
    PHP:

    aduluads.php contents code
    <?php
    include("tadb.php");
    $totalads=mysql_query("SELECT * FROM aduluads order by t");
    $ta=mysql_num_rows($totalads); 
    srand(time());
    $random = (rand()%$ta);
    $sql="select * from aduluads where t='$random'";
    $result=mysql_query($sql);
    while (list($t,$product)
          =mysql_fetch_row($result))
    {
    echo $product;
    }
    mysql_free_result($result);
    ?>
    PHP:
    thanks for azizny.
     
    Adulu, Aug 16, 2007 IP
  9. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Someone would help me?
     
    Adulu, Aug 17, 2007 IP
  10. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Adulu, Aug 18, 2007 IP
  11. andymayo

    andymayo Guest

    Messages:
    652
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #11
    andymayo, Jul 10, 2008 IP
  12. yanton

    yanton Peon

    Messages:
    508
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I have been wrestling with this problem, and finally found the solution that worked for me.

    I needed to include a php external file in my vbulletin forum.

    I found the answer here: http://www.vbulletin.com/forum/showthread.php?173937-How-to-Include-a-PHP-or-HTML-File

    This goes into the 'Add new plugin' page as the php code (no need to use <? opener and closer):

    ob_start();
    include('path/to/this/file/myfile.php');
    $includedphp = ob_get_contents();
    ob_end_clean();

    (obviously get the path correct, using ../../ if required)

    then paste $includedphp into the location to call in the php file, in my case the footer.

    I used parse_templates as the hook location.

    whew, got it sorted at last ... yipee
     
    yanton, Feb 22, 2010 IP