boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can someone help me find something...

 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
Mizkie



Joined: 19 Mar 2003
Posts: 51
Location: Bloomington, IN

PostPosted: Tue Jul 22, 2003 12:47 am    Post subject: Can someone help me find something... Reply with quote

I'm looking for something that lists all of the posts in a certain category (by date, abc, or whatever). I need to add an article/content part to my site that isn't connected to the blogs so much. I just need something that shows the date, title, and author, then has the title linking to the article.

If anyone has seen a hack that could do this and posts it, thanks.
_________________
Mick

HSS = High School Sucks
Back to top
View user's profile Send private message Visit poster's website AIM Address
afterefx



Joined: 13 Jun 2003
Posts: 25
Location: Texas

PostPosted: Thu Jul 24, 2003 7:37 am    Post subject: Reply with quote

look up b2stats
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Mizkie



Joined: 19 Mar 2003
Posts: 51
Location: Bloomington, IN

PostPosted: Thu Jul 24, 2003 8:41 pm    Post subject: Reply with quote

thanks... but I'm looking for something that when I call a variable, it shows all the posts in the category, but only the titles, date, and author... I'm not even sure if this is a hack.
_________________
Mick

HSS = High School Sucks
Back to top
View user's profile Send private message Visit poster's website AIM Address
mikelittle



Joined: 11 May 2002
Posts: 376
Location: UK

PostPosted: Thu Jul 24, 2003 10:45 pm    Post subject: Reply with quote

Hi,
Try this:
Code:

<?php
/** Get n latest posts
 ** outputs the results directly into the page it's called from.
 ** Params: cat (default 1) - The category to use
 **         num (default 5) - Number of posts to get
 **         before (default '') - text/html to output before each item
 **         after (default "<br />\n") - text/html to output after each item
 */
function get_lastestpostsbycategory($cat = 1, $num = 5, $before='', $after="<br />\n") {
    global $siteurl, $blogfilename, $tableposts, $tableusers, $querystring_start, $querystring_equal, $querystring_separator;
    $date_format = '%d/%m/%Y'; // change this for different format
    $sql = "SELECT $tableposts.ID, post_title, DATE_FORMAT($tableposts.post_date, '$date_format') AS formatted_date, user_nickname " .
           " FROM $tableposts LEFT JOIN $tableusers ON  $tableusers.ID = $tableposts.post_author " .
           " WHERE post_category = $cat " .
           " ORDER BY post_date DESC LIMIT $num";
    $result = mysql_query($sql) or die(mysql_error());
    while ($row = mysql_fetch_object($result)) {
        echo $before.$row->formatted_date.' - <a href="'.$siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal.$row->ID.'">'.stripslashes($row->post_title).'</a> by '.$row->user_nickname.$after;
    }
}
?>

Put this code in a file called postsbycat.php (or add it to b2template.functions.php)

Then in your template use
Code:

    <?php include_once('postsbycat.php'); ?>
    <?php get_lastestpostsbycategory(2, 15);  ?>


Where the first parameter to the function call is the category, and the second number is the limit for the number of posts. You could set this to a large number if you wanted to show all posts in that category.

Hope this helps,
Mike
_________________
Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't."
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Mizkie



Joined: 19 Mar 2003
Posts: 51
Location: Bloomington, IN

PostPosted: Thu Jul 24, 2003 10:56 pm    Post subject: Reply with quote

Oh man, thanks. that's just what I needed.
_________________
Mick

HSS = High School Sucks
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group