derron Posted July 26, 2014 Share Posted July 26, 2014 (edited) Can someone on here give me a .Php code that takes the 3 most recent posts from a certain thread on my forums and shows them on the homepage of my website. Edited July 26, 2014 by derron Link to comment Share on other sites More sharing options...
0 Lock Down Posted July 26, 2014 Share Posted July 26, 2014 What software are you using for the home page? content. portal, uportal or your own html? Link to comment Share on other sites More sharing options...
0 derron Posted July 26, 2014 Author Share Posted July 26, 2014 What software are you using for the home page? content. portal, uportal or your own html? The page is my own html Link to comment Share on other sites More sharing options...
0 Lock Down Posted July 26, 2014 Share Posted July 26, 2014 So do you know any php? The zipped forum comes with a folder called tools. In it is a program called ssi and a folder called ssi_templates. You can copy those to your forum folder and use that to create what you want. If you do not know php code I will fix it. But if you do know any php try it yourself and I will help you finish it. Link to comment Share on other sites More sharing options...
0 derron Posted July 26, 2014 Author Share Posted July 26, 2014 So do you know any php? The zipped forum comes with a folder called tools. In it is a program called ssi and a folder called ssi_templates. You can copy those to your forum folder and use that to create what you want. If you do not know php code I will fix it. But if you do know any php try it yourself and I will help you finish it. I have no .php knowledge Link to comment Share on other sites More sharing options...
0 Lock Down Posted July 26, 2014 Share Posted July 26, 2014 Where is the html for the display of the posts? Link to comment Share on other sites More sharing options...
0 derron Posted July 27, 2014 Author Share Posted July 27, 2014 Where is the html for the display of the posts? <div class="news"> <div class="sub_page_c"> <div id="spc_head"><p>Title Here</p></div> <div id="spc_cont"> <div align="center" class="dot"> Description Here</a><br> <div align="right"> <font color="FFCC99"> Date Here </font> </div> </div> </div> </div> <div class="sub_page_c"> <div id="spc_head"><p>Title Here</p></div> <div id="spc_cont"> <div align="center" class="dot"> Description Here<br><br> <div align="right"> <font color="FFCC99"> Date Here </font> </div> </div> </div> </div> <div class="sub_page_c"> <div id="spc_head"><p>Title Here</p></div> <div id="spc_cont"> <div align="center" class="dot"> Description Here</a><br> <div align="right"> <font color="FFCC99"> Date Here </font> </div> </div> </div> </div> That's the code from my site for where i want the posts to show up. Link to comment Share on other sites More sharing options...
0 Lock Down Posted July 27, 2014 Share Posted July 27, 2014 There is no title on posts only topics. There is no description on topics or posts. Link to comment Share on other sites More sharing options...
0 derron Posted July 27, 2014 Author Share Posted July 27, 2014 (edited) Can you just write me the .php code and i can just implement it into my site myself Edited July 27, 2014 by derron Link to comment Share on other sites More sharing options...
0 Lock Down Posted July 27, 2014 Share Posted July 27, 2014 Ok I will give you the code to get all information from one topic showing the 3 latest posts.. <?php error_reporting(E_ALL); /* +-------------------------------------------------------------------------- | USAGE: +-------------------------------------------------------------------------- Simply call this script via PHP includes, or SSI .shtml tags to generate content on the fly, streamed into your own webpage. +-------------------------------------------------------------------------- | To show last 3 posts in reverse chronological last post date order from a single topic +-------------------------------------------------------------------------- include("http://domain.com/forums/ssi.php?topic_id=12345&post_count=3"); /*noLibHook*//*TERANOTE: remove additional /* */ /** * Main executable wrapper. * * Set-up and load module to run * * @package IP.Board * @author Matt Mecham * @version 3.0 */ define( 'CCS_GATEWAY_CALLED', TRUE ); // Prevents redirect checks in ipsRegistry define( 'IPS_ENFORCE_ACCESS', TRUE ); // Prevents force login setting from returning a login page define( 'IPB_THIS_SCRIPT', 'public' ); require_once( './initdata.php' );/*noLibHook*/ require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );/*noLibHook*/ require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );/*noLibHook*/ /** * Path to SSI templates directory * */ define( 'SSI_TEMPLATES_DIR', DOC_IPS_ROOT_PATH."ssi_templates" ); /** * Maximum number of posts to show * */ /* Go... */ $reg = ipsRegistry::instance(); $reg->init(); $ssi = new ssi( $reg ); class ssi { function __construct( ipsRegistry $registry ) { $this->registry = $registry; $this->DB = $this->registry->DB(); $this->settings =& $this->registry->fetchSettings(); $this->request =& $this->registry->fetchRequest(); $this->cache = $this->registry->cache(); $this->caches =& $this->registry->cache()->fetchCaches(); $this->member = $this->registry->member(); $this->memberData =& $this->registry->member()->fetchMemberData(); $max_posts = $count = 3; if ( $this->request['topic_id'] ) { $topicId = $this->request['topic_id'] ; if ($this->request['post_count']) {$count = $this->request['post_count'];} } else { fatal_error("Fatal error: no topic id specified"); } //---------------------------------------- // Get the topics, member info and other stuff //---------------------------------------- $this->DB->build( array( 'select' => 'p.*', 'from' => array( 'posts' => 'p' ), 'where' => "topic_id = ".$topicId, 'add_join' => array( 0 => array( 'select' => 't.*', 'from' => array( 'topics' => 't' ), 'where' => "p.topic_id=".$topicId, 'type' => 'inner' ) ), 'order' => 'p.pid DESC', 'limit' => array( 0, $count ) ) ); $this->DB->execute(); if ( ! $this->DB->getTotalRows() ) { fatal_error("Could not get the information from the database"); } $HTML = ''; while ( $i = $this->DB->fetch() ) { // echo "<pre><br>";print_r($i);echo "</pre>"; $to_echo = array ( 'topic_title' => str_replace( '&#', '&#', $i['title'] ), 'topic_id' => $i['tid'], 'topic_link' => $this->settings['base_url']."showtopic=".$i['tid'], 'last_poster_id' => $i['last_poster_id'], 'last_post_name' => $i['last_poster_name'], 'last_post_time' => $this->registry->getClass('class_localization')->getDate( $i['last_post'] , 'LONG', 1 ), 'timestamp' => $i['last_post'], 'starter_id' => $i['starter_id'], 'starter_name' => $i['starter_name'], 'board_url' => $this->settings['board_url'] , 'board_name' => $this->settings['board_name'], 'rfc_date' => date( 'r', $i['last_post'] ) ); $HTML .= ' <div class="sub_page_c"> <div id="spc_head"><p>Title Here</p></div> <div id="spc_cont"> <div align="center" class="dot"> Description Here</a><br> <div align="right"> <font color="FFCC99"> Date Here </font> </div> </div> </div> </div> <div class="sub_page_c"> <div id="spc_head"><p>'.$to_echo['title'].'</p></div> <div id="spc_cont"> <div align="center" class="dot"> '.$to_echo['topic_link'].'<br><br> <div align="right"> <font color="FFCC99"> '.$to_echo['rfc_date'].' </font> </div> </div> </div> </div>'; } print $HTML ; //---------------------------------------- // Print bottom... //---------------------------------------- exit(); } function fatal_error( $error ) { print $error; exit(); } } Link to comment Share on other sites More sharing options...
0 derron Posted July 27, 2014 Author Share Posted July 27, 2014 What do I replace this line with? echo "<pre><br>";print_r($to_echo);echo "</pre>"; Link to comment Share on other sites More sharing options...
0 Lock Down Posted July 27, 2014 Share Posted July 27, 2014 Why did you ask for the php code to get the information without the html if you had no idea how to use it? I updated the my first reply with html code it so you can use it. Link to comment Share on other sites More sharing options...
0 derron Posted July 27, 2014 Author Share Posted July 27, 2014 What did my last post say? You replace that line with your html something like this <<<HTML <div class="sub_page_c"> <div id="spc_head"><p>Title Here</p></div> <div id="spc_cont"> <div align="center" class="dot"> Description Here</a><br> <div align="right"> <font color="FFCC99"> Date Here </font> </div> </div> </div> </div> <div class="sub_page_c"> <div id="spc_head"><p>{$to_echo['title']}</p></div> <div id="spc_cont"> <div align="center" class="dot"> {$to_echo['topic_link']}<br><br> <div align="right"> <font color="FFCC99"> {$to_echo['rfc_date']} </font> </div> </div> </div> </div> HTML; Why did you ask for the php code to get the information without the html if you had no idea how to use it If I give you full access to my site can you just set it all up for me? Link to comment Share on other sites More sharing options...
0 Lock Down Posted July 27, 2014 Share Posted July 27, 2014 Pm me with the site info , ftp or ssh login. I will look at it when I get a chance. Link to comment Share on other sites More sharing options...
0 derron Posted July 27, 2014 Author Share Posted July 27, 2014 Okay deal *meant latest 3 topics in a thread not posts I messaged you the info Link to comment Share on other sites More sharing options...
0 Lock Down Posted July 28, 2014 Share Posted July 28, 2014 You need to fix your html but the ssi.php works fine . You only have 1 topic so it only shows this Welcome! Sun, 08 Jun 2014 00:42:41 Link to comment Share on other sites More sharing options...
Question
derron
Can someone on here give me a .Php code that takes the 3 most recent posts from a certain thread on my forums and shows them on the homepage of my website.
Edited by derronLink to comment
Share on other sites
18 answers to this question
Recommended Posts