Vbullitin / XML feed?

Sledgehammer70Sledgehammer70 California Icrontian
edited January 2006 in Internet & Media
Okay call me dumb or stupid, but when it comes to HTML, PHP etc.. I am just that... But I am trying to learn :) I think it is funny I know how to build and fix comps... but I can't build or mod forums :( I guess it is always one or the other :) and for the select few who can do both I appricate your hard work..

I am wanting to show my current top 5 to 10 threads on my home page, and I am also trying to create a section on my forums where I can post news and it shows up on the home page. From what I hear this is a complicated task. But I am dying to learn... I don't know if this is where you use XML feeds or Rss stuff. but any help is appricated. maybe pointing me in the right direction or just slapping me one on one via Vent, or TS.... Like I said any help is appricated. I know the knowledge dwells among this site..... I just need to harness it.

Comments

  • Sledgehammer70Sledgehammer70 California Icrontian
    edited January 2006
    I should note I know the coding to create the XML or a RSS feed.. but how, what where when do I make it all work ?



    // ######################################################
    // ## configuration
    // ##
    // ## $xml_file= 'http://www.vbulletin.com/forum/external.php?type=xml';
    // ## Adjust this variable to point to your XML feed
    $xml_file = 'http://www.vbulletin.com/forum/external.php?type=xml';

    // ## configuration end
    // ######################################################


    $is_item = false;
    $tag = '';
    $title = '';
    $description = '';
    $link = '';
    $n = 0;

    $url_array = parse_url($xml_file);
    $filename = strrchr($url_array, '/');
    $realpath = substr($url_array, 0, (strlen($url_array) - strlen($filename)));
    $forumlink = $url_array . '://' . $url_array . $realpath . '/showthread.php?t=';

    function character_data($parser, $data)
    {
    global $is_item, $tag, $title, $author, $date, $time;
    if ($is_item)
    {
    switch ($tag)
    {
    case "TITLE":
    $title .= $data;
    break;

    case "AUTHOR":
    $author .= $data;
    break;

    case "DATE":
    $date .= $data;
    break;

    case "TIME":
    $time .= $data;
    break;
    }
    }
    }

    function begin_element($parser, $name, $attribs)
    {
    global $is_item, $tag, $attribute;
    if ($is_item)
    {
    $tag = $name;
    }
    else if ($name == "THREAD")
    {
    $is_item = true;
    $attribute = $attribs[ID];
    }
    }

    function end_element($parser, $name)
    {
    global $is_item, $title, $author, $date, $time, $xml_output, $attribute, $forumlink;
    if ($name == "THREAD")
    {
    $description = $author . " @ " . $date . "/" . $time;
    $xml_output .= "<dt><strong><a href='" . $forumlink . $attribute . "'>" . htmlspecialchars(trim($title)) . "</a></strong></dt><dd>" . htmlspecialchars(trim($description)) . "</dd>";
    $title = "";
    $author = "";
    $date = "";
    $time = "";
    $attribute = "";
    $is_item = false;
    }
    }


    $parser = xml_parser_create();

    xml_set_element_handler($parser, "begin_element", "end_element");
    xml_set_character_data_handler($parser, "character_data");
    $fp = fopen($xml_file,"r");

    while ($data = fread($fp, 4096))
    {
    xml_parse($parser, $data, feof($fp));
    }

    fclose($fp);
    xml_parser_free($parser);

    Make sure to adjust the $xml_file variable at the very top of the code you just added.
    Add the following code to wherever on that page you want to display the output:


    echo $xml_output;
  • Sledgehammer70Sledgehammer70 California Icrontian
    edited January 2006
    I get how it works But I just need help making it work....bahh so fustrated :(
  • kanezfankanezfan sunny south florida Icrontian
    edited January 2006
    you would get a lot more help on vbulletin's forums. I think the only person that could help you here is shorty and he's very busy.
  • ShortyShorty Manchester, UK Icrontian
    edited January 2006
    Create a PHP page called getrss.php

    and put all the code from your first post in it.. EXCEPT:


    Make sure to adjust the $xml_file variable at the very top of the code you just added.
    Add the following code to wherever on that page you want to display the output:

    echo $xml_output;


    Make sure you don't leave any characters out and also that you keep the original formatting from that post on VBulletin that you copied the code from ;)

    Also make sure the first line contains

    [php]
    <?php
    [/php]

    and the last line has

    [php]?>[/php]

    Those that the opening and closing "tags" to tell the web server to use PHP :)

    Your homepage will be MUST be a .php page. I am assuming here that it is :)

    Open your homepage. At the very top before any HTML.. add

    [php]
    <?php
    require_once '<pathtoyour_getrss.php>';
    [/php]

    Those lines tell the webserver processing the page to use PHP and include that getrss.php page. You will need to change < pathtoyour_getrss.php > to reflect where it is really on your server (eg.. /forum/customcode).

    Then in your HTML.. wherever you want the threads to go ... simply put...

    [php]
    <?php echo $xml_output; >?
    [/php]

    That will then add that content to that spot :)
  • Sledgehammer70Sledgehammer70 California Icrontian
    edited January 2006
    Thanks Shorty! But I am having an issue! I think I have it all ironed out but this! http://www.bfmetournaments.com
  • Sledgehammer70Sledgehammer70 California Icrontian
    edited January 2006
    what I did!
    I created a new file called getrss.php adding the following and only the following! the entire text above with the PHP tags!

    Now I went to my index.php page and added the required PHP line... above all the HTML.

    I than added the echo within my HTML and my page fatal errors :(
  • Sledgehammer70Sledgehammer70 California Icrontian
    edited January 2006
    Did I Mention That........ Shorty Is The Man?
  • ShortyShorty Manchester, UK Icrontian
    edited January 2006
    :cool:
  • Sledgehammer70Sledgehammer70 California Icrontian
    edited January 2006
    http://www.bfmetournaments.com

    Now I just need it to fit and look good :)
Sign In or Register to comment.