Jump to:

1841 Posts in 1599 Topics by 558 members

Blog Module

SilverStripe Forums » Blog Module » order blog by sort not by date

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 1545 Views
  • prawnstar
    Avatar
    Community Member
    116 Posts

    order blog by sort not by date Link to this post

    /blog/code/BlogEntry.php

    // By specifying a callback, you can alter the SQL, or sort on something other than date.
          if($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $filter, $limit, $order);

    How do you specify?

    Thanks!
    C.b

  • carlos
    Avatar
    Community Member
    41 Posts

    Re: order blog by sort not by date Link to this post

    Hi prawnstar,

    Which version of blog are you using?

    This is in BlogTree class now tag 0.4.1.

    What it does is calling a function that you define in order to get blog entries sorted by a different criteria.

    hope it helps.

    cheers

  • prawnstar
    Avatar
    Community Member
    116 Posts

    Re: order blog by sort not by date Link to this post

    Thanks Carlos!

    I was using 0.4.0, but I'm downloading 0.4.1 now.

    C.b

  • prawnstar
    Avatar
    Community Member
    116 Posts

    Re: order blog by sort not by date Link to this post

    Hi Carlos,

    I downloaded 0.4.1 but still don't see a way to change this behavior without changing the function inside the /blog/code/BlogTree.php file. Is there no way to change this without hacking the script?

    I'm extending the BlogHolder class. Can it be overridden there?

    Thanks!
    Chris.b

  • carlos
    Avatar
    Community Member
    41 Posts

    Re: order blog by sort not by date Link to this post

    hi prawnstar,

    you can do this

    class MyClass extends Page {

    function MyFunc(){
    // return entries sorted by something....
    }
    }

    then in your code (where you want to return the entries something like this:

    $blog = DataObject::get_one('BlogHolder');

    $entries = $blog->Entries('','','',array('MyClass','MyFunc'),'');

    In this way you can create your own function and return entries sorted by whatever you want without change the core code.

    Hope it helps

    cheers
    Carlos

    1545 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.