Jump to:

1835 Posts in 1139 Topics by 554 members

Blog Module

SilverStripe Forums » Blog Module » Return blog posts by author

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1259 Views
  • socks
    Avatar
    Community Member
    190 Posts

    Return blog posts by author Link to this post

    I'd like to link the author's name to return all of the posts by that author. Any help is much appreciated.

    Thanks

  • prawnstar
    Avatar
    Community Member
    116 Posts

    Re: Return blog posts by author Link to this post

    *bump*

    I'm trying to do something very similar. I'd like to return the BlogHolder with a list of BlogEntries based on something other than /tag/ or /date/.

    In the BlogTree.php comments I see:

    * @param callback retrieveCallback A function to call with pagetype, filter and limit for custom blog sorting or filtering

    But that's a little over my head to fully grasp how to do that.

    Thanks,
    chris

  • Juanitou
    Avatar
    Community Member
    322 Posts

    Re: Return blog posts by author Link to this post

    Hi!

    That’s quite easy, since I managed to do it… ;-)

    On the basis of the provided widgets, I made an AuthorWidget. Then, you have to modify the allowed actions in BlogHolder_Controller, provide some get functions, etc. I don’t really remember the details. Ah, also the templates, for sure. I have packed the whole modified module for you to try it but beware: it was done before the actual version that includes a BlogTree and also includes some modifications I did in order to get special chars showing correctly. Sorry, but I have not the time to explain or support it better, you’ll have to figure out by yourselves.

    Good luck!
    Juan

    Attached Files
  • prawnstar
    Avatar
    Community Member
    116 Posts

    Re: Return blog posts by author Link to this post

    Hi, Juanitou,

    Thanks for the reply. I looked at the files you posted. Ideally, I would like to avoid hacking the core blog files. The ones you posted are a bit different than the current version with BlogTree.php, but I get the idea.

    Looking at the blog core code, it looks like the functionality to sort by author was supposed to be there, but obviously it doesn't work.

    Instead of trying to fix it, I just extended the BlogHolder/BlogEntry and made a function to return based on author:

    function GetAuthor(){
    return DataObject::get('BlogEntry',"Author = '$this->Author'",'','','');
    }

    Then on my extended BlogHolderExtended page I just use <% control GetAuthor %> to iterate through instead of <% include BlogSummary %>

    Not the prettiest, but it was an acceptable solution.

    Hope that helps someone.

    Chris

  • ber860520
    Avatar
    Community Member
    3 Posts

    Re: Return blog posts by author Link to this post

    i have a similar problem, but mine includes another fields( added by me ), i was trying to put a function in the blogholder_controller and trying to display the results and i couldnt, im desesperated LOL, I wa trying to contact you but your emails doesnt appear, mine is ber860520@hotmail.com

    1259 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.