https://www.icyphoenix.com/viewtopic.php?f=35&t=8693 ----------------------------------- juggalo_master Thu 13 Sep, 2012 05:03 How Could I Go About Showing A List Of Recent Posts ----------------------------------- i want to show a list of recent topics/posts on my site through the templates. like this: IMG Tags And %20 Together Won't Work... posted by: Paul_RS1date: Mon 21 Aug, 2006 18:19 and so on. if it can't be done then its ok i will try something else by using rss script but i would whether use the forum system before i use javascript ----------------------------------- spydie Thu 13 Sep, 2012 09:16 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- What about recent posts block? you find it in cms ----------------------------------- juggalo_master Thu 13 Sep, 2012 13:07 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- nope won't work check out my site http://www.animenewsinc.net/ you will see what i mean. i am wanting to add through template variables or so on how to show recent posts as a list not just a number. i already figured out how to show the numbers of total posts and topics now i want to show recent posts/topics. my site is using tpl files but the main part doesn't have the over_all files included. which means it doesn't show the forum as part of it ----------------------------------- mort Thu 13 Sep, 2012 14:38 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- From memory, it's recent_topics block either static or scrolling - narrow or wide. :?: ----------------------------------- juggalo_master Thu 13 Sep, 2012 23:12 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- thanks mort i will look at it and the php and tpl file. it seems like you seem to know what i am talking about lol. [code] if(!function_exists('cms_block_recent_topics')) { function cms_block_recent_topics() { global $db, $cache, $config, $template, $user, $lang, $block_id, $cms_config_vars; $template->_tpldata['recent_topic_row.'] = array(); $except_forums = build_exclusion_forums_list(); $current_time = time(); $extra = "AND t.topic_time <= $current_time"; $sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username, u.user_active, u.user_color FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u WHERE t.forum_id NOT IN (" . $except_forums . ") AND t.topic_status <> 2 AND p.post_id = t.topic_last_post_id AND p.poster_id = u.user_id $extra ORDER BY p.post_time DESC LIMIT " . $cms_config_vars['md_num_recent_topics'][$block_id]; $result = $db->sql_query($sql); $number_recent_topics = $db->sql_numrows($result); $recent_topic_row = array(); while ($row1 = $db->sql_fetchrow($result)) { $recent_topic_row[] = $row1; } $db->sql_freeresult($result); if($cms_config_vars['md_recent_topics_style'][$block_id]) { $style_row = 'scroll'; } else { $style_row = 'static'; } $template->assign_block_vars($style_row, ''); for ($i = 0; $i < $number_recent_topics; $i++) { $recent_topic_row[$i]['topic_title'] = censor_text($recent_topic_row[$i]['topic_title']); // Convert and clean special chars! $topic_title = htmlspecialchars_clean($recent_topic_row[$i]['topic_title']); $template->assign_block_vars($style_row . '.recent_topic_row', array( 'U_TITLE' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $recent_topic_row[$i]['forum_id'] . '&' . POST_TOPIC_URL . '=' . $recent_topic_row[$i]['topic_id'] . '&' . POST_POST_URL . '=' . $recent_topic_row[$i]['post_id']) . '#p' . $recent_topic_row[$i]['post_id'], 'L_TITLE' => $topic_title, 'L_BY' => $lang['By'], 'L_ON' => $lang['POSTED_ON'], 'S_POSTER' => colorize_username($recent_topic_row[$i]['user_id'], $recent_topic_row[$i]['username'], $recent_topic_row[$i]['user_color'], $recent_topic_row[$i]['user_active']), 'S_POSTTIME' => create_date_ip($config['default_dateformat'], $recent_topic_row[$i]['post_time'], $config['board_timezone']) ) ); } } } $block_variables = array( array('Number of recent topics', 'number of topics displayed', 'md_num_recent_topics', '', '', '1', 'recent_topics', '10'), array('Recent Topics Style', 'choose static display or scrolling display', 'md_recent_topics_style', 'Scroll,Static', '1,0', '3', 'recent_topics', '1') ); [/code] how do i get this to work properly i can't figure out how to get it to show. it doesn't have the template vars and i am confused with how to get it to work. ----------------------------------- mort Fri 14 Sep, 2012 01:30 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- Sucking something out of the CMS would be a lot of work I would imagine. :( Here's a stand-alone you could clean up and play with. Copy the script to myrecent.php, edit the vars at the top and put it in the root. [spoiler][code linenumbers=false] '. $topic_limit .' last topics '; // ############## output ############## $where_forums = ( $special_forums == '0' ) ? '' : 't.forum_id IN ('. $forum_ids .') AND '; $sql = "SELECT t.*, f.forum_id, f.forum_name, u.username AS first_poster, u.user_id AS first_poster_id, u2.username AS last_poster, u2.user_id AS last_poster_id, p.post_username AS first_poster_name, p2.post_username AS last_poster_name, p2.post_time FROM ". $table_prefix ."topics t, ". $table_prefix ."forums f, ". $table_prefix ."users u, ". $table_prefix ."posts p, ". $table_prefix ."posts p2, ". $table_prefix ."users u2 WHERE $where_forums t.topic_poster = u.user_id AND f.forum_id = t.forum_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id ORDER BY t.topic_last_post_id DESC LIMIT $topic_limit"; $result = mysql_query($sql); if( !$result ) { die('SQL Statement Error: '. mysql_error()); exit(); } $line = array(); while( $row = mysql_fetch_array($result) ) { $line[] = $row; } for( $i = 0; $i < count($line); $i++ ) { $forum_id = $line[$i]['forum_id']; $forum_url = $root_path .'viewforum.php?f='. $forum_id; $topic_id = $line[$i]['topic_id']; $topic_url = $root_path .'viewtopic.php?t='. $topic_id; $topic_title = ( strlen($line[$i]['topic_title']) < $topic_length ) ? $line[$i]['topic_title'] : substr(stripslashes($line[$i]['topic_title']), 0, $topic_length) .'...'; $topic_type = ( $line[$i]['topic_type'] == '2' ) ? 'Announcement ': ''; $topic_type .= ( $line[$i]['topic_type'] == '3' ) ? 'Global Announcement ': ''; $topic_type .= ( $line[$i]['topic_type'] == '1' ) ? 'Sticky ': ''; $views = $line[$i]['topic_views']; $replies = $line[$i]['topic_replies']; $first_time = date('d.m.Y', $line[$i]['topic_time']); $first_author = ( $line[$i]['first_poster_id'] != '-1' ) ? ''. $line[$i]['first_poster'] .'' : ( ($line[$i]['first_poster_name'] != '' ) ? $line[$i]['first_poster_name'] : 'guest' ); $last_time = date('d.m.Y', $line[$i]['post_time']); $last_author = ( $line[$i]['last_poster_id'] != '-1' ) ? $line[$i]['last_poster'] : ( ($line[$i]['last_poster_name'] != '' ) ? $line[$i]['last_poster_name'] : 'guest' ); $last_url = ''. $last_author .''; // ############## output ############## echo ' '. $topic_type .''. $topic_title .' '. $line[$i]['forum_name'] .': '. $last_url .' '. $last_time .' '; // ############## output ############## } echo ''; mysql_close(); ?>[/code][/spoiler] And of course the mark-up is pretty basic. :mryellow: ----------------------------------- juggalo_master Fri 14 Sep, 2012 02:35 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- alright but how would i go about showing that in my footer of my main site? i figured that works but what i am looking for is how to add the code to my php file that i already have set up for the tpl file. what i am wanting is like a list that will show in my footer under recent posts. if you look at my site you will see what i am looking for. http://www.animenewsinc.net/ look at footer at the recent post section. [code] Icy Phoenix Debug] PHP Notice: in file /top.php on line 14: mysql_connect() [function.mysql-connect]: Access denied for user 'devildo2'@'localhost' (using password: NO) Unable to select server. [/code] when i try to include the file and echo out the results i get this error. i don't know how to fix it either i tried putting in the info for the mysql myself but then i get table doesn't exist. [code] SQL Statement Error: Table 'devildo2_phpb362.topics' doesn't exist[/code] when i enter the details alone. ----------------------------------- mort Fri 14 Sep, 2012 03:38 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- Change the top of the file (With your paths) to: [code linenumbers=false] That's what I did. ;) [img]http://www.icyphoenix.com/files/images/8840/untitled_1.jpg[/img] ----------------------------------- juggalo_master Fri 14 Sep, 2012 03:50 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- still mysql error. i use to use this: [code] include("/home/devildo2/public_html/top.php"); [/code] i tried your new way but it isn't working. mind you i don't have inlcude overall_ files on my site. i am using the custom pages for ip to show my main pages. ----------------------------------- mort Fri 14 Sep, 2012 04:03 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- It's supposed to be stand-alone and not require any IP files other than config.php. put myrecent.php in the root of your forum and call it up. http://blah/myrecent.php and it should come up - let me know if it works? :mrviolet: Just a minute - It appears that you have IP in the root of your public folder, so this part of the path is not required. forum/ ----------------------------------- juggalo_master Fri 14 Sep, 2012 04:12 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- oh i am looking for a way to include it into my file by putting the code into my custom page file and put the template vars into the tpl. i am not looking for a standalone version lol. but that can come in handy tho so thanks for that part. but what i am wanting is like a blog roll or blog post list but with the recent posts or topics. either one will work. i just to put something so when visitors come to my site they see the recent posts/topics and can click on the title or link and read more of it. pretty much it's like wordpress recent topic list widget but instead of it being wordpress it does the recent posts/topics from the icyphoenix. ----------------------------------- mort Fri 14 Sep, 2012 04:32 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- [quote user="juggalo_master" post="56815"]what i am wanting is like a blog roll or blog post list but with the recent posts or topics. either one will work. i just to put something so when visitors come to my site they see the recent posts/topics and can click on the title or link and read more of it. [/quote] That's what it does. ? I imagine that you could create a function for that code and put it in your .php file along with creating a [b]template vars array[/b] for the VARS in these strings and paste the vars into your template rather than have php echo the html. [code linenumbers=false] '. $topic_type .''. $topic_title .' '. $line[$i]['forum_name'] .': '. $last_url .' '. $last_time .' ';[/code] ----------------------------------- juggalo_master Fri 14 Sep, 2012 14:11 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- tried that i got nothing lol. i might of putten it in a wrong way but i will try again. ----------------------------------- mort Sat 15 Sep, 2012 03:31 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- Here's some script I modified for IP. :P And if this doesn't work, then [b][i]one[/i][/b] of us is doing something wrong. :lol: [b]recent.php:[/b] [spoiler][code linenumbers=false] - http://smartor.is-root.com * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ /** * * @Extra credits for this file * * */ define('IN_ICYPHOENIX', true); if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './'); if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); include(IP_ROOT_PATH . 'common.' . PHP_EXT); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup(); // End session management // // START Recent Topics // $template->set_filenames(array( 'body' => 'recent.tpl') ); ########### Config the number of recent topics ############ // Number of Recent Topics (not Forum ID) $CFG['number_recent_topics'] = '10'; // Excluding forums for Recent Topics, eg. '2,4,10' (note: My Recent Topics script has its own permission checking, so you can leave this variable blank) $CFG['exceptional_forums'] = ''; ############################################################ $sql = "SELECT * FROM ". FORUMS_TABLE . " ORDER BY forum_id"; if (!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql); } $forum_data = array(); while( $row = $db->sql_fetchrow($result) ) { $forum_data[] = $row; } $is_auth_ary = array(); $is_auth_ary = auth(AUTH_ALL, AUTH_LIST_ALL, $user->data, $forum_data); if( $CFG['exceptional_forums'] == '' ) { $except_forum_id = '\'start\''; } else { $except_forum_id = $CFG['exceptional_forums']; } for ($i = 0; $i < count($forum_data); $i++) { if ((!$is_auth_ary[$forum_data[$i]['forum_id']]['auth_read']) or (!$is_auth_ary[$forum_data[$i]['forum_id']]['auth_view'])) { if ($except_forum_id == '\'start\'') { $except_forum_id = $forum_data[$i]['forum_id']; } else { $except_forum_id .= ',' . $forum_data[$i]['forum_id']; } } } $sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u WHERE t.forum_id NOT IN (" . $except_forum_id . ") AND t.topic_status <> 2 AND p.post_id = t.topic_last_post_id AND p.poster_id = u.user_id ORDER BY p.post_id DESC LIMIT " . $CFG['number_recent_topics']; if (!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query recent topics information', '', __LINE__, __FILE__, $sql); } $number_recent_topics = $db->sql_numrows($result); $recent_topic_row = array(); while ($row = $db->sql_fetchrow($result)) { $recent_topic_row[] = $row; } for ($i = 0; $i < $number_recent_topics; $i++) { $template->assign_block_vars('recent_topic_row', array( 'U_TITLE' => append_sid('viewtopic.' .PHP_EXT .'?' . POST_POST_URL . '=' . $recent_topic_row[$i]['post_id']) . '#' .$recent_topic_row[$i]['post_id'], 'L_TITLE' => $recent_topic_row[$i]['topic_title'], 'U_POSTER' => append_sid('profile.' .PHP_EXT . '?mode=viewprofile&' . POST_USERS_URL . "=" . $recent_topic_row[$i]['user_id']), 'S_POSTER' => $recent_topic_row[$i]['username'], 'S_POSTTIME' => date('d.m.Y', $recent_topic_row[$i]['post_time']) ) ); } // // END - Recent Topics // $template->pparse('body'); ?> [/code][/spoiler] [b]recent.tpl[/b] [spoiler][code linenumbers=false]
{L_RECENT_TOPICS}
» {recent_topic_row.L_TITLE}
by {recent_topic_row.S_POSTER} on {recent_topic_row.S_POSTTIME}

{L_RECENT_TOPICS}
» {recent_topic_row.L_TITLE}
by {recent_topic_row.S_POSTER} on {recent_topic_row.S_POSTTIME}

[/code][/spoiler] ----------------------------------- Mighty Gorgon Sat 15 Sep, 2012 12:10 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- Smart way to solve it [b]mort[/b]. :lol: There is another way, which is using an RSS parser, so you can include recent posts directly from RSS... you can find plenty on the web. ----------------------------------- mort Sat 15 Sep, 2012 12:49 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- [quote user="Mighty Gorgon" post="56850"]There is another way, which is using an RSS parser, so you can include recent posts directly from RSS... you can find plenty on the web.[/quote] I'm not that [i]Smartor[/i] - Prefer to stick with what I think is enough for me. :P ----------------------------------- Mighty Gorgon Sun 16 Sep, 2012 13:16 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- [quote user="mort" post="56856"]I'm not that [i]Smartor[/i] - Prefer to stick with what I think is enough for me. :P[/quote] He he he... but it would be easier to use a premade RSS reader than code a SQL which is run from another page on Icy Phoenix DB... anyway you did great, and following the toughest way. Well done. 8) ----------------------------------- juggalo_master Tue 18 Sep, 2012 00:35 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- cool it worked. now i can implant it into my main site and have it looking the way it did. ----------------------------------- Joshua203 Wed 19 Sep, 2012 12:12 Re: How Could I Go About Showing A List Of Recent Posts ----------------------------------- Marked SOLVED ...you are allowed to do this by yourself in the future juggalo_master (right bottom of the page .. Title Edit) please do :wink: