Support » Plugin: Rich Reviews » Date order

  • Resolved TrishaM


    Can you please tell me where in the current version of this plugin code is the function to show reviews in order of newest (first) to oldest (last)?

    I have hacked version 1.4 pretty extensively in order to make it do the following necessary things:

    – Display radio buttons to choose the category for the review (so that we can display the form on only one page but let reviewers choose which product category the review is for)

    – Display the stars on aggregate snippets, removed the “out of 5 stars” text so it just shows the number of stars followed by “based on [x] reviews”

    – Display the date the review was submitted after the reviewer’s name

    – Added some custom classes to the output so that I don’t have to add a lot of extra styles to my style.css to force styles as I want them to be

    I also fixed the function that displays full vs. empty stars in aggregates snippets, because if the average was less than 4, it only displayed the number of full stars plus 1 empty star (for example a product that averaged 3 stars would show 3 full stars plus 1 empty star, that made it look like 3 out of 4 possible, instead of 3 full stars plus 2 empty stars, which is the accurate average of 3 out of 5 possible).

    SO NOW I can’t really update the plugin without having to go back and re-do all these hacks……if you can tell me where you put in the code to reverse the date order I’ll add that manually to my hacked-up version.

    THANKS!! This really is a great plugin, much better than a lot of other review/testimonial plugins, we just needed it to do some very specific things so I had to modify it.

Viewing 11 replies - 1 through 11 (of 11 total)
  • I found this in the newest version:

    $sql = "SELECT id asidid`,
    date_time as datetime,
    reviewer_name as reviewername,
    reviewer_email as revieweremail,
    review_title as reviewtitle,
    review_rating as reviewrating,
    review_text as reviewtext,
    review_status as reviewstatus,
    reviewer_ip as reviewerip FROM $this->sqltable ” . $whereStatement . ” ” . $limitStatement . ‘ ORDER BY id DESC’;`

    This is sorting on ID, which assumes that ID order is always going to be the same as date/time order……a logical assumption, however, before we got the plugin installed and working, we had a lot of reviews submitted to us by email that we wanted to include, so we entered them manually, and then modified the database (using phpMyAdmin) to change the entry date to reflect the true date of the review submission…..this means that the ID order is NOT the same as the date/time order.

    It would make more sense to use ORDER BY ‘datetime’ DESC, which I tried, but it doesn’t work…..all the reviews are still in ID order, not date order.

    Any suggestions would be MOST appreciated!

    I think that $limitStatement . ‘ ORDER BY id DESC’;`
    should be $limitStatement . ‘ ORDER BY date_time DESC’;`

    TrishaM! I would very much like to know the code you used to

    “Display the date the review was submitted after the reviewer’s name”

    Just let me know which files and what to add! Thank you so much!!!

    hello @dmpilotwings

    First, it’s important to know that I am using version 1.4.2 of the Rich Reviews plugin – so if you’re using a newer version pay close attention to the code, not the line numbers and my hacks *may not* work with a newer version.

    The file to modify is in the plugin folder/ rich-reviews.php.

    Be SURE to backup your file FIRST!!

    That said, the function to *display* the review is what you want to modify, that’s called “function fp_display_review($review)” (I believe in the original version 1.4.2 it starts at line #727).

    The line I CHANGED was this one:

    $output .= '<div class="rr_review_name"> - ' . $rName . '</div>
    			<div class="clear"></div>';

    I ADDED this: ('. $rDisplayDate .') so the NEW line is this:

    $output .= '<div class="rr_review_name"> Submitted by: ' . $rName . ' ('. $rDisplayDate .')</div>
    			<div class="clear"></div>';

    That puts the date in parenthesis, so if you don’t want it in parenthesis just leave those out and use $rName . $rDisplayDate .'</div>

    I hope this helps.

    @criannen – I’m sorry for not responding sooner. 🙂

    I did try that change, as well as $limitStatement . ‘ ORDER BY datetime DESC’;` since date_time was defined in the variables as ‘datetime’…but neither worked……it still did not sort into the order I wanted……it still sorted them into the date they were entered into the database…..which is ID order.

    Hi Trisha thanks for your speedy response!

    I too am using 1.4.2 (Though I see there is a brand new (huge!) update just a few days ago to version 1.5.0) …thinking about it…

    Anyways, the “(‘. $rDisplayDate .’)” addition to the code did not work, as that function is not described anywhere in the code. Did you add this too? The good news is, I added “(‘. $rDateTime .’)” in place of your “(‘. $rDisplayDate .’)” instructions and I now have a date/time stamp on each review! …. But it’s ugly, and I don’t want the timestamp :/

    How do I write a simple function like “$rDisplayDate” and make it so it just shows the date, preferably in Month/Day/Year format… and even better, the month display as a three-letter word (ie. 2 = Feb, 5 = May)?

    Trisha you rock!! Thank you so much for your time! Check out our page:

    And does any of this stuff help??

    @dmpilotwings – please accept my apologies – I did indeed add something else to the plugin that I had forgotten about……it is the variable $rDisplayDate that converts the datetime to a string and formats it the way I needed… is also in the same function, fp_display_review……

    Add this: $rDisplayDate = date('M d, Y',strtotime($review['datetime']));

    I put it just below the variable for $rDateTime = $review['datetime'];

    The part where I format the *appearance* of the date is the ‘M d, Y’ – you can change that to suit your needs……you should be able to find what you need here:

    I hope this helps!

    Trisha you’re a Genius!! It’s exactly what I needed!! Thank you thank you thank you! For anyone else who wants a date stamp that looks like this:

    Here are the lines you need to add in Bold:

    function fp_display_review($review) {
    $rID = $review[‘idid’];
    $rDateTime = $review[‘datetime’];
    $rDisplayDate = date(‘M d, Y’,strtotime($review[‘datetime’]));

    $rName = $this->fp_nice_output($review[‘reviewername’], FALSE);


    $output .= ‘<div class=”rr_review_text”><span class=”drop_cap”>“</span>’ . $rText . ‘”</div>’;
    $output .= ‘<div class=”rr_review_name”> – ‘ . $rName . ‘ ‘. $rDisplayDate .'</div>
    <div class=”clear”></div>’;
    $output .= ‘</div>’;
    return $output;

    the above line wasn’t bolded completely.
    $output .= ‘<div class=”rr_review_name”> – ‘ . $rName . ‘ ‘. $rDisplayDate .'</div>
    <div class=”clear”></div>’;

    Plugin Author Ian


    TrishaM and dmpilotwings, the date does look really nice right there! We will put that in as an option ASAP 🙂

    Also, sorting by date is definitely a no brainer, that’s gotta go in immediately as well 🙂

    We’ve got another developer (everyone say ‘Hi’ to Austin!) now working on this, so updates and features are now going to be coming fast and furious!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Date order’ is closed to new replies.