I have a form with a single dropdown input. Upon successful submission, a cookie is set with the dropdown's value. This form is inside of a pages tag, in particular the 'k_paginated_top' section. I am using the cookie value to dictate the 'orderby' and 'order' parameters of the aforementioned pages tag. After the page reloads upon a successful submission, the pages tag still displays the cloned pages in the old ordering. However if I manually reload the page again, the proper cloned page ordering is displayed.
In summary, the problem I am experiencing is only on the first page reload (immediately after form submission), the 'orderby_set' and 'order_set' variables are not being set at their new values for the pages tag. Any ideas on a solution?
Update:
This sorting ability is more appropriately implemented with query strings than cookies. An added bonus is that you don't have to sacrifice caching.
- Code: Select all
<cms:set sorting="<cms:get_cookie 'sorting' />" />
<cms:if sorting >
<cms:if sorting='new' ><cms:set orderby_set='publish_date' /><cms:set order_set='desc' /></cms:if>
<cms:if sorting='old' ><cms:set orderby_set='publish_date' /><cms:set order_set='asc' /></cms:if>
<cms:if sorting='low' ><cms:set orderby_set='product_price' /><cms:set order_set='asc' /></cms:if>
<cms:if sorting='high' ><cms:set orderby_set='product_price' /><cms:set order_set='desc' /></cms:if>
</cms:if>
<cms:pages limit='15' paginate='1' orderby=orderby_set order=order_set>
<cms:if k_paginated_top >
<cms:form name='sorting_form' method='post' anchor='0' enctype="multipart/form-data">
<label for="sorting">Sort by:</label>
<cms:input type='dropdown' name='sorting' opt_values="Date Added: New to Old=new | Date Added: Old to New=old | Price: Low to High=low | Price: High to Low=high" opt_selected=sorting tabindex="1" onchange="this.form.submit()" />
<cms:if k_success >
<cms:set_cookie name='sorting' value=frm_sorting expire='0' />
</cms:if>
</cms:form>
</cms:if>
...
</cms:pages>
In summary, the problem I am experiencing is only on the first page reload (immediately after form submission), the 'orderby_set' and 'order_set' variables are not being set at their new values for the pages tag. Any ideas on a solution?
Update:
This sorting ability is more appropriately implemented with query strings than cookies. An added bonus is that you don't have to sacrifice caching.