[Skip to main content](#vessel-content)

#   Sort comments on frontend product page

##

- **[hawkeyentjc](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile")**
- [![hawkeyentjc's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile") Topic Author
- [ Offline](/forum/user/6372-hawkeyentjc)

Less More

- Posts: 50
- Thank you received: 1
-
-

14 years 1 month ago [\#66771](#66771) by [hawkeyentjc](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile")  *[Sort comments on frontend product page](/forum/2-general-talk-about-hikashop/66771-sort-comments-on-frontend-product-page#66771 "Is there any way to add an front-end option for users to sort the vote/comments on product page according to 3 things?  &#42; Most Helpful  &#42; Latest Comment  &#42; Highest Rating  Currently, we can only sort it from the backend and only based on 2 criteria -&gt; Date &amp; Helpful.  If there's an frontend option for users to sort, it would be great. I believe users would want to have the freedom to choose how they want to view the comments instead of pre-set on backend, especially if a certain product has over 100+ comments.  Any way to achieve this in the current 1.6.0?  Thanks in advance.")* was created by *[hawkeyentjc](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile")*

Is there any way to add an front-end option for users to sort the vote/comments on product page according to 3 things?

- Most Helpful
- Latest Comment
- Highest Rating

Currently, we can only sort it from the backend and only based on 2 criteria -&gt; Date &amp; Helpful.

If there's an frontend option for users to sort, it would be great. I believe users would want to have the freedom to choose how they want to view the comments instead of pre-set on backend, especially if a certain product has over 100+ comments.

Any way to achieve this in the current 1.6.0?

Thanks in advance.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzY2NzcxLXNvcnQtY29tbWVudHMtb24tZnJvbnRlbmQtcHJvZHVjdC1wYWdlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

14 years 1 month ago [\#66972](#66972) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Re: Sort comments on frontend product page](/forum/2-general-talk-about-hikashop/66771-sort-comments-on-frontend-product-page#66972 "Is there any way to add an front-end option for users to sort the vote/comments on product page according to 3 things?  &#42; Most Helpful  &#42; Latest Comment  &#42; Highest Rating  Currently, we can only sort it from the backend and only based on 2 criteria -&gt; Date &amp; Helpful.  If there's an frontend option for users to sort, it would be great. I believe users would want to have the freedom to choose how they want to view the comments instead of pre-set on backend, especially if a certain product has over 100+ comments.  Any way to achieve this in the current 1.6.0?  Thanks in advance.")*

Hi hawkeyentjc,

Most helpful &amp;&amp; Highest rating is the same thing, and latest comment is like date.

To do this, you will have to edit the file "yourSite/components/com_hikashop/views/vote/view.html.php" and in the function "listing()" add a variable like: Code:

$sort_comments = JRequest::getString('sort_comment',''); if($sort_comments == "date"){ $order = ' ORDER BY &#96;vote_date&#96; ASC'; }else if($sort_comments == "helpful"){ $order=' ORDER BY &#96;vote_useful&#96; DESC, &#96;vote_date&#96; ASC'; }

After the lines: Code:

if($vote_comment_sort == "date"){ $order = ' ORDER BY &#96;vote_date&#96; ASC'; }

And edit the view "vote / listing" in the frontend to add a single dropdown which display the 2 possibilities and reload the page when the user select one of these option and set the variable $sort_comments to "date" or "helpful".

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzY2NzcxLXNvcnQtY29tbWVudHMtb24tZnJvbnRlbmQtcHJvZHVjdC1wYWdlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[hawkeyentjc](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile")**
- [![hawkeyentjc's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile") Topic Author
- [ Offline](/forum/user/6372-hawkeyentjc)

Less More

- Posts: 50
- Thank you received: 1
-
-

14 years 1 month ago [\#67829](#67829) by [hawkeyentjc](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile")  Replied by *[hawkeyentjc](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile")* on topic *[Re: Sort comments on frontend product page](/forum/2-general-talk-about-hikashop/66771-sort-comments-on-frontend-product-page#67829 "Is there any way to add an front-end option for users to sort the vote/comments on product page according to 3 things?  &#42; Most Helpful  &#42; Latest Comment  &#42; Highest Rating  Currently, we can only sort it from the backend and only based on 2 criteria -&gt; Date &amp; Helpful.  If there's an frontend option for users to sort, it would be great. I believe users would want to have the freedom to choose how they want to view the comments instead of pre-set on backend, especially if a certain product has over 100+ comments.  Any way to achieve this in the current 1.6.0?  Thanks in advance.")*

Hi Xavier,

I've added the lines to the view.html.php as you suggested.

As for adding the code in "vote / listing" to display the dropdown with the two options, will you be able help to provide some guidance on the coding? As I'm not too familiar with the codes. Thank you so much!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzY2NzcxLXNvcnQtY29tbWVudHMtb24tZnJvbnRlbmQtcHJvZHVjdC1wYWdlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86322
- Thank you received: 14281
-
-

14 years 1 month ago [\#67930](#67930) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Sort comments on frontend product page](/forum/2-general-talk-about-hikashop/66771-sort-comments-on-frontend-product-page#67930 "Is there any way to add an front-end option for users to sort the vote/comments on product page according to 3 things?  &#42; Most Helpful  &#42; Latest Comment  &#42; Highest Rating  Currently, we can only sort it from the backend and only based on 2 criteria -&gt; Date &amp; Helpful.  If there's an frontend option for users to sort, it would be great. I believe users would want to have the freedom to choose how they want to view the comments instead of pre-set on backend, especially if a certain product has over 100+ comments.  Any way to achieve this in the current 1.6.0?  Thanks in advance.")*

You can add such HMTL at the top of that file :

&lt;select name="sort_comment" onchange="this.form.submit();"&gt;
&lt;option value="date"&gt;Latest Comment&lt;/option&gt;
&lt;option value="helpful"&gt;Most helpful&lt;/option&gt;
&lt;/select&gt;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzY2NzcxLXNvcnQtY29tbWVudHMtb24tZnJvbnRlbmQtcHJvZHVjdC1wYWdlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[hawkeyentjc](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile")**
- [![hawkeyentjc's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile") Topic Author
- [ Offline](/forum/user/6372-hawkeyentjc)

Less More

- Posts: 50
- Thank you received: 1
-
-

14 years 3 weeks ago [\#69838](#69838) by [hawkeyentjc](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile")  Replied by *[hawkeyentjc](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile")* on topic *[Re: Sort comments on frontend product page](/forum/2-general-talk-about-hikashop/66771-sort-comments-on-frontend-product-page#69838 "Is there any way to add an front-end option for users to sort the vote/comments on product page according to 3 things?  &#42; Most Helpful  &#42; Latest Comment  &#42; Highest Rating  Currently, we can only sort it from the backend and only based on 2 criteria -&gt; Date &amp; Helpful.  If there's an frontend option for users to sort, it would be great. I believe users would want to have the freedom to choose how they want to view the comments instead of pre-set on backend, especially if a certain product has over 100+ comments.  Any way to achieve this in the current 1.6.0?  Thanks in advance.")*

Hi nicolas,

I tried your method. In a way, it did work, but another issue came up.

Each time I select the option, it will refresh the page. However, if my shopping cart has 1 of item X before the page refreshes, it would duplicate the item X after the page refreshes. Meaning, after the page is refreshed, now my cart has 2 of items X, even though I didn't add to cart the item X.

Any solution for this?

Thanks.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzY2NzcxLXNvcnQtY29tbWVudHMtb24tZnJvbnRlbmQtcHJvZHVjdC1wYWdlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86322
- Thank you received: 14281
-
-

14 years 2 weeks ago [\#70023](#70023) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Sort comments on frontend product page](/forum/2-general-talk-about-hikashop/66771-sort-comments-on-frontend-product-page#70023 "Is there any way to add an front-end option for users to sort the vote/comments on product page according to 3 things?  &#42; Most Helpful  &#42; Latest Comment  &#42; Highest Rating  Currently, we can only sort it from the backend and only based on 2 criteria -&gt; Date &amp; Helpful.  If there's an frontend option for users to sort, it would be great. I believe users would want to have the freedom to choose how they want to view the comments instead of pre-set on backend, especially if a certain product has over 100+ comments.  Any way to achieve this in the current 1.6.0?  Thanks in advance.")*

Hi,

Instead of the line:
&lt;select name="sort_comment" onchange="this.form.submit();"&gt;

you should use something like that:
&lt;select name="sort_comment" onchange="var ids = document.getElementsByName('product_id'); ids[0].value=0; this.form.submit();"&gt;

That should avoid the product from being added to the cart.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzY2NzcxLXNvcnQtY29tbWVudHMtb24tZnJvbnRlbmQtcHJvZHVjdC1wYWdlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[hawkeyentjc](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile")**
- [![hawkeyentjc's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile") Topic Author
- [ Offline](/forum/user/6372-hawkeyentjc)

Less More

- Posts: 50
- Thank you received: 1
-
-

14 years 2 weeks ago [\#70211](#70211) by [hawkeyentjc](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile")  Replied by *[hawkeyentjc](/forum/user/6372-hawkeyentjc "View hawkeyentjc's Profile")* on topic *[Re: Sort comments on frontend product page](/forum/2-general-talk-about-hikashop/66771-sort-comments-on-frontend-product-page#70211 "Is there any way to add an front-end option for users to sort the vote/comments on product page according to 3 things?  &#42; Most Helpful  &#42; Latest Comment  &#42; Highest Rating  Currently, we can only sort it from the backend and only based on 2 criteria -&gt; Date &amp; Helpful.  If there's an frontend option for users to sort, it would be great. I believe users would want to have the freedom to choose how they want to view the comments instead of pre-set on backend, especially if a certain product has over 100+ comments.  Any way to achieve this in the current 1.6.0?  Thanks in advance.")*

Thanks Nicolas for the workaround. The page refresh no longer adds to cart.

There's another issue about the Select Option button. The default value is always "Latest Comment". Two things happen here:

1. Even if you click "Most Helpful", after the page refresh it returns to "Latest Comment" again.
2. Since that's the case, you have no way of selecting "Latest Comment" because it always appears there by default.

Any solution to this? Thanks.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzY2NzcxLXNvcnQtY29tbWVudHMtb24tZnJvbnRlbmQtcHJvZHVjdC1wYWdlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

14 years 2 weeks ago -  14 years 2 weeks ago [\#70289](#70289) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Re: Sort comments on frontend product page](/forum/2-general-talk-about-hikashop/66771-sort-comments-on-frontend-product-page#70289 "Is there any way to add an front-end option for users to sort the vote/comments on product page according to 3 things?  &#42; Most Helpful  &#42; Latest Comment  &#42; Highest Rating  Currently, we can only sort it from the backend and only based on 2 criteria -&gt; Date &amp; Helpful.  If there's an frontend option for users to sort, it would be great. I believe users would want to have the freedom to choose how they want to view the comments instead of pre-set on backend, especially if a certain product has over 100+ comments.  Any way to achieve this in the current 1.6.0?  Thanks in advance.")*

Hi,

Try this code in the view "vote / listing": Code:

&lt;?php $current_url = hikashop_currentURL(); $set = JRequest::getString('sort_comment',''); if(!empty($set)) $current_url = preg_replace('/\/sort_comment-'.$set.'/','',$current_url); // If using SEF $current_url = preg_replace('/&amp;sort_comment='.$set.'/','',$current_url); // If not using SEF ?&gt; &lt;select name="sort_comment" onchange="document.location.href='&lt;?php echo $current_url; ?&gt;/sort_comment-'+this.value+''"&gt; &lt;!-- using SEF --&gt; &lt;select name="sort_comment" onchange="document.location.href='&lt;?php echo $current_url; ?&gt;&amp;sort_comment='+this.value+''"&gt; &lt;!-- not using SEF --&gt; &lt;option &lt;?php if($set == 'date')echo "selected"; ?&gt; value="date"&gt;Latest Comment&lt;/option&gt; &lt;option &lt;?php if($set == 'helpful')echo "selected"; ?&gt; value="helpful"&gt;Most helpful&lt;/option&gt; &lt;/select&gt;

Where the comments are presented, choose one or the other method, not both.

Last edit: 14 years 2 weeks ago by [Xavier](/forum/user/4105-xavier "View Xavier's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzY2NzcxLXNvcnQtY29tbWVudHMtb24tZnJvbnRlbmQtcHJvZHVjdC1wYWdlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.093 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
