SOLVED How Could I Go About Showing A List Of Recent Posts
SOLVED How Could I Go About Showing A List Of Recent Posts
Comments |
Re: How Could I Go About Showing A List Of Recent Posts
|
What about recent posts block?
you find it in cms
|
spydie [ Thu 13 Sep, 2012 09:16 ]
|
|
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
|
juggalo_master [ Thu 13 Sep, 2012 13:07 ]
|
|
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.
|
mort [ Thu 13 Sep, 2012 14:38 ]
|
|
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.
- 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')
- );
-
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.
|
juggalo_master [ Thu 13 Sep, 2012 23:12 ]
|
|
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.
<?php
// ############ Edit below ########################################
$topic_length = '30'; // length of topic title
$topic_limit = '5'; // limit of displayed topics
$special_forums = '0'; // specify forums ('0' = no; '1' = yes)
$forum_ids = ''; // IDs of forums; separate them with a comma
$root_path = '/forum/'; // link path
// ############ Edit above ########################################
$path = dirname(__FILE__);
include_once('config.php');
mysql_connect($dbhost, $dbuser, $dbpasswd) OR die('Unable to select server.');
mysql_select_db($dbname) OR die('Unable to select database.');
// ############## output ##############
echo '<table width="100%" cellpadding="1" cellspacing="1" border="0" align="center">
<tr>
<th colspan="2">'. $topic_limit .' last topics</th>
</tr>';
// ############## 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' ) ? '<a href="'. $root_path .'profile.php?mode=viewprofile&u='. $line[$i]['first_poster_id'] .'">'. $line[$i]['first_poster'] .'</a>' : ( ($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 = '<a href="'. $root_path .'viewtopic.php?p='. $line[$i]['topic_last_post_id'] .'#'. $line[$i]['topic_last_post_id'] .'">'. $last_author .'</a>';
// ############## output ##############
echo '<tr>
<td valign="top" nowrap="nowrap">'. $topic_type .'<a href="'. $topic_url .'">'. $topic_title .'</a></td>
</tr>
<tr>
<td><a href="'. $forum_url .'">'. $line[$i]['forum_name'] .'</a>: '. $last_url .' '. $last_time .'</td>
</tr>';
// ############## output ##############
}
echo '</table>';
mysql_close();
?>
And of course the mark-up is pretty basic.
|
mort [ Fri 14 Sep, 2012 01:30 ]
|
|
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.
- 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.
-
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.
- SQL Statement Error: Table 'devildo2_phpb362.topics' doesn't exist
when i enter the details alone.
|
juggalo_master [ Fri 14 Sep, 2012 02:35 ]
|
|
Re: How Could I Go About Showing A List Of Recent Posts
|
Change the top of the file (With your paths) to:
<?php
// ############ Edit below ########################################
$topic_length = '30'; // length of topic title
$topic_limit = '5'; // limit of displayed topics
$special_forums = '0'; // specify forums ('0' = no; '1' = yes)
$forum_ids = ''; // IDs of forums; separate them with a comma
$config_path = './../forum/'; // path to config.php
$root_path = '/forum/'; // link path
// ############ Edit above ########################################
$path = dirname(__FILE__);
include($config_path .'config.php');
mysql_connect($dbhost, $dbuser, $dbpasswd) OR die('Unable to select server.');
mysql_select_db($dbname) OR die('Unable to select database.');
// ############## output ##############
Add this to your .tpl file where you want it to appear.
<?php
include "myrecent.php";
?>
That's what I did.
|
mort [ Fri 14 Sep, 2012 03:38 ]
|
|
Re: How Could I Go About Showing A List Of Recent Posts
|
still mysql error.
i use to use this:
- <!-- PHP -->include("/home/devildo2/public_html/top.php"); <!-- ENDPHP -->
-
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.
|
juggalo_master [ Fri 14 Sep, 2012 03:50 ]
|
|
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?
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/
|
mort [ Fri 14 Sep, 2012 04:03 ]
|
|
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.
|
juggalo_master [ Fri 14 Sep, 2012 04:12 ]
|
|
Re: How Could I Go About Showing A List Of Recent Posts
|
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.
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 template vars array for the VARS in these strings and paste the vars into your template rather than have php echo the html.
<td valign="top" nowrap="nowrap">'. $topic_type .'<a href="'. $topic_url .'">'. $topic_title .'</a></td>
</tr>
<tr>
<td><a href="'. $forum_url .'">'. $line[$i]['forum_name'] .'</a>: '. $last_url .' '. $last_time .'</td>
</tr>';
|
mort [ Fri 14 Sep, 2012 04:32 ]
|
|
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.
|
juggalo_master [ Fri 14 Sep, 2012 14:11 ]
|
|
Re: How Could I Go About Showing A List Of Recent Posts
|
Here's some script I modified for IP.
And if this doesn't work, then one of us is doing something wrong.
recent.php:
<?php
/**
* Recent Topics Block
* @package Icy Phoenix
* @version $Id$
* @copyright (c) Smartor <smartor_xp@hotmail.com> - 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');
?>
recent.tpl
<!-- Static Recent -->
<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
<tr>
<td class="cat"><span class="genmed"><b>{L_RECENT_TOPICS}</b></span></td>
</tr>
<tr>
<td class="row1" align="left"><span class="gensmall">
<!-- BEGIN recent_topic_row -->
» <a href="{recent_topic_row.U_TITLE}">{recent_topic_row.L_TITLE}</a><br />
by <a href="{recent_topic_row.U_POSTER}">{recent_topic_row.S_POSTER}</a> on {recent_topic_row.S_POSTTIME}<br /><br />
<!-- END recent_topic_row -->
</span></td>
</tr>
</table>
<br />
<!-- Scrolling Recent -->
<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
<tr>
<td class="cat"><span class="genmed"><b>{L_RECENT_TOPICS}</b></span></td>
</tr>
<tr>
<td class="row1" align="left"><span class="gensmall">
<marquee id="recent_topics" behavior="scroll" direction="up" height="200" scrolldelay="100" scrollamount="2">
<!-- BEGIN recent_topic_row -->
» <a href="{recent_topic_row.U_TITLE}" onmouseover="document.all.recent_topics.stop()" onmouseout="document.all.recent_topics.start()">{recent_topic_row.L_TITLE}</a><br />
by <a href="{recent_topic_row.U_POSTER}" onmouseover="document.all.recent_topics.stop()" onmouseout="document.all.recent_topics.start()">{recent_topic_row.S_POSTER}</a> on {recent_topic_row.S_POSTTIME}<br /><br />
<!-- END recent_topic_row -->
</marquee>
</span></td>
</tr>
</table>
<br />
Edited by mort, Sat 15 Sep, 2012 13:01: Upgrade the template function |
mort [ Sat 15 Sep, 2012 03:31 ]
|
|
Re: How Could I Go About Showing A List Of Recent Posts
|
Smart way to solve it mort.
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.
|
Mighty Gorgon [ Sat 15 Sep, 2012 12:10 ]
|
|
|
Was this topic useful?
Was this topic useful?
|
Page 1 of 2
|
|
|