On these pages are my WordPress plugins, the odd article and my Support Forum.

For my random rantings on everything else please visit my blog at Yellow Swordfish

WP Plugins


Articles

If you find any of my plugins useful, please comsider a donation towards my running costs.

Thank you

Current User: Guest
Please consider registering

 
Search Forums:


 




Help with sf_author_posts Tag

UserPost

3:34 pm
27 Jun 2008


kbevington

Member

posts 20

 
1

Putting this tag into my front page, multiple times for multiple authors… It works great, except, is there a way to limit what it returns to say the last 2 posts?

I am aware of the sf_latest_posts_expanded tag (have not used it), can the author tag be expressed in a similar way?

Thx

Kevin

2:50 am
28 Jun 2008


kbevington

Member

posts 20

 
2

any help with this would sure be appreciated!


Thx

Kevin

3:13 am
28 Jun 2008


Mr Papa

Moderator

Arizona, USA

posts 1452

 
3

not currently, but if you are not afraid of a little bit of php, you can make a slight mod to the tag…

in sf-tags.php, line 373 change

function sf_author_posts($author_id, $showforum=true, $showdate=true)

to

function sf_author_posts($author_id, $showforum=true, $showdate=true, $limit=0)

and then change line 383

    $sql = “SELECT DISTINCT post_id, forum_id, topic_id, post_date, post_index FROM “.SFPOSTS.” WHERE user_id = $author_id ORDER BY post_date DESC”;   

to

if ($limit > 0)
{
$limit = 'LIMIT '.$limit;
} else {
$limit = '';
}
$sql = “SELECT DISTINCT post_id, forum_id, topic_id, post_date, post_index FROM “.SFPOSTS.” WHERE user_id = $author_id ORDER BY post_date DESC $limit”;

Then just add another parameter at the end of the call to the tag with the desired number of posts to be returned…  A value of zero means return all posts for the author id… 

Or you could just replace the

DESC $limit in my above with DESC LIMIT 2 for your example… just depends on how flexible you want to be…

Please note, I havent tested the code I just entered, but it should get you close if not what you want…  If you prefer, you can PM me and I can mod the file and send it to you if you like… 

I will also open a ticket to get the tag modified with this change for the next release as its a pretty good idea..

11:47 am
28 Jun 2008


kbevington

Member

posts 20

 
4

Sent a pm…


Thanks

Kevin

12:16 pm
28 Jun 2008


Mr Papa

Moderator

Arizona, USA

posts 1452

 
5

replied and emailed you a file…  let me know how it works…



Reply to Topic: Help with sf_author_posts Tag

NOTE: New Posts are subject to administrator approval before being displayed

Guest Name (Required):

Guest EMail (Required):

Guest URL (required)

Math Required!
What is the sum of: 1 + 8        (Required)

Topic Reply:


 
 

About the Stuff at Yellow Swordfish forum

Currently Online:

derixc

12 Guests

Maximum Online: 71

Forums:

Groups: 3

Forums: 16

Topics: 1954

Posts: 13264

Members:

There are 927 members

There are 800 guests


Yellow Swordfish has made 5050 posts

Top Posters:

Mr Papa - 1452

-Radio- - 521

ovizii - 106

jfv - 82

angelic007 - 70

Administrator: Yellow Swordfish | Moderators: Yellow Swordfish, Mr Papa, -Radio-


© Simple:Press Forum - Version 3.1.4 (Build 357)