Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module /

Discuss the Blog Module.

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

order blog by sort not by date


Reply


5 Posts   1657 Views

Avatar
prawnstar

Community Member, 127 Posts

7 October 2010 at 11:50am

/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

Avatar
carlos

Community Member, 41 Posts

7 October 2010 at 5:23pm

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

Avatar
prawnstar

Community Member, 127 Posts

8 October 2010 at 4:54am

Thanks Carlos!

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

C.b

Avatar
prawnstar

Community Member, 127 Posts

8 October 2010 at 5:37am

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

Avatar
carlos

Community Member, 41 Posts

8 October 2010 at 2:32pm

Edited: 08/10/2010 2:33pm

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