Hey all!

I've set up the guestbook block on a clients site - how do I get the contents of the guestbook to be displayed in order from newest to oldest (rather than the default oldest-newest).

Help much appreciated !

View Replies: View Best Answer
ymne replied on at Permalink Reply
Just open the file
Go to line 187
And change the value "DESC" to "ASC"

function getEntries($order = "DESC") {

function getEntries($order = "ASC") {

myFullFlavour replied on at Permalink Reply
Ahh easy as!

Developers, any chance for this option in future releases of the block?
krgetler replied on at Permalink Reply

I was in good shape changing the sort order by following ymne's directions.

However, when I upgraded to V5.4.1 it no longer sorts per "ASC".

Has anyone else experienced this? Do I need to restart for it to pick up the change? I am running it from a commercially hosted company so I am not sure how I would restart any deamons.

Thanks for thinking about it.

LucasAnderson replied on at Permalink Reply
Nah, what happened was your upgrade overwrites core files and you had modified core files instead of copying them and moving them out of the /concrete directory.

If you want to modify core files (those in the /concrete folder) you need to make a copy of them, and then place them in your root folder structure mimicing where they would be in the /concrete folder structure.


Copy /concrete/blocks/guestbook/controller.php



(You may need to create those folders.)

You'll notice this is outside the /concrete folder.

This way, going forward if you upgrade your site it will not overwrite any changes you made to that file.
khunbill1 replied on at Permalink Reply 1 Attachment
Hello, I am using C5 version

When I go to the /concrete/blocks/guestbook/controller.php

There is no line 187 or anything close. All I see is this
   defined('C5_EXECUTE') or die("Access Denied.");
   class GuestbookBlockController extends Concrete5_Controller_Block_Guestbook {      
   class GuestBookBlockEntry extends Concrete5_Controller_Block_GuestbookEntry {

In this version of C5 is there another file that needs to be modified?
Under the "guestbook" folder I have looked in all of these [see image] Not sure if image is viewable - here is the file list

I have a 2nd question:
I am moving over to a C5 site from an old one I created on Front Page. I'd like to "import" the guest messages I have there and will probably have to do it manually. What I would like to do is have the original posting date appear. I have tried in XP to change the system date and time but that has no effect as there seems to be an internal C5 clock - if so How can I access it and change the date?

jasteele12 replied on at Permalink Best Answer Reply
Overrides work differently (better) in 5.6+

Place this in blocks/guestbook/controller.php:

<?php defined('C5_EXECUTE') or die('Access Denied.');
class GuestbookBlockController extends concrete5_Controller_Block_Guestbook {
    * gets a list of all guestbook entries for the current block
    * @param string $order ASC|DESC
    * @return array
   function getEntries($order = 'DESC') {  // Changed from ASC
      $bo = $this->getBlockObject();
      $c = Page::getCurrentPage();
      return GuestBookBlockEntry::getAll($this->bID, $c->getCollectionID(), $order);
class GuestBookBlockEntry extends concrete5_Controller_Block_GuestbookEntry { }

Basically we are now only overriding the getEntries() function to default to DESC instead of ASC (line 190 in concrete/core/controllers/blocks/guestbook.php).

Untested, but pretty sure that should work :)

2nd Question - The entries are being posted based on the CURRENT_TIMESTAMP used by the MySQL server.

Hope that helps,

khunbill1 replied on at Permalink Reply

Thank you - Works like a charm.

I deleted the minimal code I showed in my questions and replaced it with yours, logged off my C5 test site and went to the guest book and posted two comments to see what would happen.

Perfect result...............

Quinta Zaragoza guest comments

Posted by adfafg on Jul 27th, 2013
three should be above 2

Posted by bill on Jul 27th, 2013
two should be lower than 3
jasteele12 replied on at Permalink Reply
Glad you got it working! You could mark my answer as best :D
khunbill1 replied on at Permalink Reply

Thanks again for the code.

On your reply to my 2nd question: "2nd Question - The entries are being posted based on the CURRENT_TIMESTAMP used by the MySQL server."
I didn't want to mess with that so I just added all my reviews from the old site under an Admin user. Everything went in perfect order.

Once done another 'issue' (that word drives me nuts but I think it applies here) came up: one has to read or scroll down to the end of the comments before seeing the Leave a Reply box. That, given the limited attention span of modern folk, maybe a disincentive to leave a comment - Could there be a bit of Side Bar code linked under text such as "Leave a Comment Now" that would go directly to the bottom of the page/form to the Leave a Reply Box?
khunbill1 replied on at Permalink Reply
jasteele123's solution works equally well. Thanks
jasteele12 replied on at Permalink Reply
jasteele12 replied on at Permalink Reply
FYI, the how-to is now a legacy tutorial that can be found here: