nanodesigns / nanosupport

Create a fully featured Support Center in your WordPress setup without any third party dependency, completely FREE. Get a built-in Knowledgebase too. The plugin is available on WordPress.org repository:
https://wordpress.org/plugins/nanosupport/
GNU General Public License v2.0
50 stars 13 forks source link

There should be a way to make the responses appear in DESC order #61

Closed mayeenulislam closed 5 years ago

mayeenulislam commented 5 years ago

User carllockett3 requested a feature that,

I would like to have the responses to the ticket in reverse order so the most recent is at the top of the page instead of scrolling down through all responses to get to the newest. I made a temp fix in the file content-single-ticket.php by adding the line $response_array = array_reverse($response_array);. This is located near the bottom of the file just above the lines:

foreach( $response_array as $response ) {
//highlight the latest response on successful submission of new response
$fresh_response = (isset($_GET['ns_success']) || isset($_GET['ns_cm_success']) ) && $found_count == $counter ? 'new-response' : '';
mayeenulislam commented 5 years ago

Thank you for suggesting a good solution beside the feature request.

array_reverse() is good.

We've another solution to suggest:

  1. Smart Templating: First of all the templates can be overridden from your theme. So no need to modify the plugin file directly. (I think you already know that)
  2. DESC order: In templates/content-single-ticket.php, in line 160 in version 0.5.0 there is an order parameter in get_comments(). Just change this to DESC instead of ASC.

I think this will solve your issue first-hand.

BTW, we're keeping this as a feature request, because there deserves a filter hook, so that without modifying the template, the user can simply filter the response query from anywhere.

carllockett3 commented 5 years ago

I can't believe I missed that in the get_comments() $args! That works as well!