How Could I Go About Showing A List Of Recent Posts »  Show posts from    to     

Icy Phoenix


Old Support Topics - How Could I Go About Showing A List Of Recent Posts



juggalo_master [ Thu 13 Sep, 2012 05:03 ]
Post subject: 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 ]
Post subject: 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 ]
Post subject: 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 ]
Post subject: 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 ]
Post subject: 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: [Hide]
  1. if(!function_exists('cms_block_recent_topics')) 
  2. function cms_block_recent_topics() 
  3. global $db, $cache, $config, $template, $user, $lang, $block_id, $cms_config_vars; 
  4.  
  5. $template->_tpldata['recent_topic_row.'] = array(); 
  6.  
  7. $except_forums = build_exclusion_forums_list(); 
  8.  
  9. $current_time = time(); 
  10. $extra = "AND t.topic_time <= $current_time"; 
  11.  
  12. $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 
  13. FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u 
  14. WHERE t.forum_id NOT IN (" . $except_forums . ") 
  15. AND t.topic_status <> 2 
  16. AND p.post_id = t.topic_last_post_id 
  17. AND p.poster_id = u.user_id 
  18. $extra 
  19. ORDER BY p.post_time DESC 
  20. LIMIT " . $cms_config_vars['md_num_recent_topics'][$block_id]; 
  21. $result = $db->sql_query($sql); 
  22. $number_recent_topics = $db->sql_numrows($result); 
  23. $recent_topic_row = array(); 
  24.  
  25. while ($row1 = $db->sql_fetchrow($result)) 
  26. $recent_topic_row[] = $row1; 
  27. $db->sql_freeresult($result); 
  28.  
  29. if($cms_config_vars['md_recent_topics_style'][$block_id]) 
  30. $style_row = 'scroll'; 
  31. else 
  32. $style_row = 'static'; 
  33.  
  34. $template->assign_block_vars($style_row, ''); 
  35.  
  36. for ($i = 0; $i < $number_recent_topics; $i++) 
  37. $recent_topic_row[$i]['topic_title'] = censor_text($recent_topic_row[$i]['topic_title']); 
  38.  
  39. // Convert and clean special chars! 
  40. $topic_title = htmlspecialchars_clean($recent_topic_row[$i]['topic_title']); 
  41. $template->assign_block_vars($style_row . '.recent_topic_row', array( 
  42. 'U_TITLE' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $recent_topic_row[$i]['forum_id'] . '&amp;' . POST_TOPIC_URL . '=' . $recent_topic_row[$i]['topic_id'] . '&amp;' . POST_POST_URL . '=' . $recent_topic_row[$i]['post_id']) . '#p' . $recent_topic_row[$i]['post_id'], 
  43. 'L_TITLE' => $topic_title, 
  44. 'L_BY' => $lang['By'], 
  45. 'L_ON' => $lang['POSTED_ON'], 
  46. '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']), 
  47. 'S_POSTTIME' => create_date_ip($config['default_dateformat'], $recent_topic_row[$i]['post_time'], $config['board_timezone']) 
  48. ); 
  49. $block_variables = array( 
  50. array('Number of recent topics', 'number of topics displayed', 'md_num_recent_topics', '', '', '1', 'recent_topics', '10'), 
  51. array('Recent Topics Style', 'choose static display or scrolling display', 'md_recent_topics_style', 'Scroll,Static', '1,0', '3', 'recent_topics', '1') 
  52. ); 
  53.  


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 ]
Post subject: 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: [ Show ]


And of course the mark-up is pretty basic. :mryellow:


juggalo_master [ Fri 14 Sep, 2012 02:35 ]
Post subject: 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: [Hide]
  1. 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) 
  2. Unable to select server. 
  3.  


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: [Hide]
  1. SQL Statement Error: Table 'devildo2_phpb362.topics' doesn't exist 


when i enter the details alone.


mort [ Fri 14 Sep, 2012 03:38 ]
Post subject: Re: How Could I Go About Showing A List Of Recent Posts
Change the top of the file (With your paths) to:

Code: [Hide] [Select]
<?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. ;)

untitled_1


juggalo_master [ Fri 14 Sep, 2012 03:50 ]
Post subject: Re: How Could I Go About Showing A List Of Recent Posts
still mysql error.

i use to use this:
Code: [Hide]
  1. <!-- PHP -->include("/home/devildo2/public_html/top.php"); <!-- ENDPHP --> 
  2.  


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 ]
Post subject: 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 ]
Post subject: 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 ]
Post subject: Re: How Could I Go About Showing A List Of Recent Posts
juggalo_master wrote: [View Post]
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.

Code: [Hide] [Select]
<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>';


juggalo_master [ Fri 14 Sep, 2012 14:11 ]
Post subject: 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 ]
Post subject: 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 one of us is doing something wrong. :lol:

recent.php:

Spoiler: [ Show ]


recent.tpl

Spoiler: [ Show ]


Mighty Gorgon [ Sat 15 Sep, 2012 12:10 ]
Post subject: Re: How Could I Go About Showing A List Of Recent Posts
Smart way to solve it mort. :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 ]
Post subject: Re: How Could I Go About Showing A List Of Recent Posts
Mighty Gorgon wrote: [View Post]
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.


I'm not that Smartor - Prefer to stick with what I think is enough for me. :P


Mighty Gorgon [ Sun 16 Sep, 2012 13:16 ]
Post subject: Re: How Could I Go About Showing A List Of Recent Posts
mort wrote: [View Post]
I'm not that Smartor - Prefer to stick with what I think is enough for me. :P

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 ]
Post subject: 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 ]
Post subject: 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:




Powered by Icy Phoenix