:::EDITED 8/18/2018::: Now tested to work with .php - check down in the thread for latest post and new notes.
This has been tested with .asp but not .php
Although it should work for both.
Some users like to create a page where new products are automatically shown.
This can be done by creating a static page and inserting the orsortby parameter just before the include line that calls up your products.
New products automatically show up on this page and they are automatically shown in the order of newest first, regardless of the sort setting you have established in your admin.
It's good for your customers and good "spider" food for the search engines.
Basically in the content area of your page (.asp version example here) you would have this.
<%orsortby=9%>
<!--#include file="vsadmin/inc/incproducts.asp"-->
It works really well.
That is until you decide to use the product filters.
Namely the sort filter where customers can resort the products to any order that you have allowed in your admin main setting where the filter is setup.
Then the
<%orsortby=9%>is ignored and the page is sorted by whatever your customer has changed that filter to.
Have no fear, Javascript (and jquery) are here to fix that for you.
<!-- Begin Re-sort -->
<script type="text/javascript">
var sortvalue = $("div.ectpfsort select.prodfilter").val();
if (sortvalue != "9") {
jQuery(document).ready(function($){
$('div.ectpfsort select.prodfilter').val(9).change();
});
}
</script>
<!-- End Re-sort -->
This above code, needs to be added to the
bottom of the static page you created
just before the closing </body> tag.
WARNING - If you do not place this at the bottom of the page, and you put it at the top, the page will get caught in an endless refresh loop because the "sort" has not been established until the page loads.
You do need to be calling jquery on the page. Check the top of your page because you may already have some jquery on your site and if you are already loading the jquery library, then you do not want it twice. That can cause issues.
If you are not, just add the line below in the
<head> </head> section of the page.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
Happy Selling.
David
ECT Power User