SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member Ultra_Tom's Avatar
    Join Date
    Mar 2001
    Location
    UK
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the way Sitepoint lists the latest posts from the forums on the homepage is really good. It keeps the homepage fresh and probably attracts a lot more people in.

    How is it done? Does vBulletin have a nice wizard that produces code to cut and paste or does it involve lots of hacking and scripting to intergrate it with the homepage?

    Ultra_Tom

  2. #2
    Freelance Web Designer KeithMcL's Avatar
    Join Date
    Oct 1999
    Location
    Dublin, Ireland
    Posts
    1,125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I also have this setup on my site ( www.webdevsites.com ) for my forums.

    Here's the code I use:
    Code:
    <?php 
    // Set this to the max number of threads to display 
    $maxthreads = 10; 
    
    require("path/to/config.php"); 
    $db=mysql_connect($servername,$dbusername,$dbpassword); 
    mysql_select_db($dbname); 
    $query="select * from thread WHERE forumid != 14 ORDER BY lastpost DESC LIMIT $maxthreads";
    $resultlatest = mysql_query($query,$db); 
    while ($latest_array = mysql_fetch_array($resultlatest)) { 
    echo "<FONT SIZE=\"2\" FACE=\"Arial, Helvetica, sans-serif\"> 
    <A HREF=\"http://www.yourdomain.com/showthread.php?threadid=$latest_array[threadid]\">$latest_array[title]</A></FONT>"; 
    } 
    
    ?>
    This works for version 1.1.5 of VBulletin. It might be different for v2, i'm not sure.

    Maybe Wayne will post the code SP use?

    rgds,

  3. #3
    SitePoint Zealot Overgrow's Avatar
    Join Date
    Jan 2001
    Location
    Your basement
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is also for 1.x vB. I pull from "categories" for my first pull and then forums for the bottom two. Here is the main site where it's used. I also put the info in arrays for easier use later (and also because I'm caching the results for 2 minutes)

    Code:
    	// Cycle through the forums, pull out the latest posts in each category, and add them to the arrays
    
    	$posttitle = array();
    	$lastposter = array();
    	$threadid = array();
    	$dateline = array();
    
    	while ($fcount < 3) {
    
    		if ($fcount == 0) {
    			$whereclause = "where forumid='1' or forumid='2' or forumid='3' or forumid='4' or forumid='5' or forumid='19'";
    		}	else if ($fcount == 1) {
    			$whereclause = "where forumid='12'";
    		}	else if ($fcount == 2) {
    			$whereclause = "where forumid='13'";
    		}
    
    		$querylatest = "SELECT title,lastposter,threadid,lastpost,forumid FROM thread ";
    		$querylatest .= $whereclause;
    		$querylatest .= " ORDER BY lastpost DESC LIMIT 1";
    
    		$resultlatest = mysql_query($querylatest,$db_connection);
    
    		if (!$resultlatest) {
    
    			print ("Unsuccessful: $querylatest<br>\n");
    			$fcount=4;
    
    		} else {
    
    			while ($latest_array = mysql_fetch_array($resultlatest)) {
    
    				if (strlen($latest_array["title"]) > 37) {
    				
    					$newtitle = substr($latest_array["title"],0,34) . "...";
    					array_push($posttitle,$newtitle);
    
    				} else { 
    					
    					array_push($posttitle,$latest_array["title"]);
    				
    				}
    				
    				array_push($lastposter,$latest_array["lastposter"]);
    				array_push($threadid,$latest_array["threadid"]);
    				array_push($dateline,date("g:i A",$latest_array["lastpost"]));
    
    			}
    			$fcount++;
    
    		}
    Overgrow the Government: The Edge Forums
    presented by Overgrow Marijuana Magazine

    *warning: adult content

  4. #4
    SitePoint Member Ultra_Tom's Avatar
    Join Date
    Mar 2001
    Location
    UK
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys, I have 1.1.5 and let you know how I get on when I get round to it.

    Ultra_Tom


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •