Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Embed a Thread to a HTML webpage

Greetings, i played some times with the Embed Vanilla Plugin but it isnt exactly that what i would like to use.

Okay here my Setup.
I use Vanilla Version 2.0.18.8
And the vanilla Blog Plugin

Now i really would like to use the News Blog (Thread) as a embed for a static html webpage.
The standard Plugin seem to create a Iframe but only for the whole Forum.

Have someone found a way to include a discussion to a HTML Static Webpage without a iframe?

Sincerly yours

Deex / Germany

Comments

  • TamaTama United Kingdom ✭✭✭
    edited July 2013

    I use php to grab the page, this code may be a bit messy but it works

    <?php
    // Vanilla DB Connection settings   
    $dbhost = "localhost";
    $dbuser = "root";
    $dbpass = ""; 
    $db = "s";
    
    $vanillaurl ="http://mysite.com/forums"; // Config for site url aka where vanill is installed
    
    // Connect to the database 
    mysql_connect("$dbhost", "$dbuser", "$dbpass")or die("Database Error: Cannot connect to database. Please contact the administrator."); 
    mysql_select_db("$db")or die("Database Error: Cannot select the database. Please contact the administrator.");
    
    
    //Configure the Category to pull from    
    $postquery = mysql_query("SELECT * FROM GDN_Discussion WHERE CategoryID='3' ORDER BY DiscussionID DESC LIMIT 5"); // Category id "3" and list 5 latest
    
    //Scan the database and process all the row entries 
        while ($row = mysql_fetch_array($postquery)) {
            $link = $row['DiscussionID'];       
            $userid = $row['InsertUserID'];
                $userquery = mysql_query("SELECT * FROM GDN_User WHERE UserID='$userid' LIMIT 1");         //Get the user who posted
                $userrow = mysql_fetch_array($userquery); 
                $username = $userrow['Name']; // Find the link and prep for link
            $name = $row['Name'];
            $body = $row['Body']; // Post content
                $body = str_replace("\n", "<br />\n", $body); // Some line breaks to make it actually work, can be removed
            $comments = $row['CountComments']; //Comment count
            $dateinserted = $row['DateInserted']; // When it was posted
            $dateinserted = date($dateinserted); // When it was posted/ convert data, buggy doesn't actually work. But no time to fix
            $link = "$vanillaurl/discussion/$link"; // The link for the header
    
            // Output all the data!
            echo "<div class='vanilla'>"; // A Wrapper for the entire entry 
            echo "<div class='vanillapostheader'><a href='$link'>$name</a></h4></div>"; // The Header/title of thread
            echo "<div style='font-style:italic; font-size:12px;'>Posted on $dateinserted by <a' href='$vanillaurl/profile/$username'>$username</a></div>"; // Posted by who and /when
            echo "<div class='vanillapostcontent' style='padding: 5px;'>$body</div>"; // Content
            echo "<small><a href='$link'>($comments comments)</a></small><br /> \n"; // Comment Count
            echo "</div>"; // Close wrapper
        }
    
    //Done
    ?>
    

    There was an error rendering this rich post.

    deexvrijvlinder
  • Hello Tama, i will begin to test it now and give you a reponse ;) thanks for the moment. I'm on it

  • deexdeex New
    edited July 2013

    Our Dev looked about it and said "Nice and dirty direct hack",

    With other words, it worked and saved us a lot of time.
    Here is a example of the use

    Thank you very much for it. I would like to contribute your work with a link in our section of copyright to your page in (Our site still alfa) but will be better for the Future ;) but it would be cool if you have a link to your own page or work ;)

  • That hack you are doing is completely unsanitised, which mean you are vulnerable to XSS attacks.

    You either need to strip all tag or, put the Body through a sanitizer like html lawed, and strip tags from the Name.

    grep is your friend.

Sign In or Register to comment.