Guest Posted January 28, 2008 Share Posted January 28, 2008 Hi there, Right now when you look at a category, or search for results, in CubeCart 4 (I'm in 4.0.3 btw), you get a way to sort your listed results by name or by price. More options might be welcome, but that's a separate issue. I'm wondering if there's a way to create text links to do the same thing, so that the user can just click once on text to sort, rather than use the pull-down and then the form. The output should look something like this: An important thing I need is the ability to show whether we're sorting by name or by price, and in what order. I was looking at viewCat.tpl in my skin, and viewCat.inc.php in the core. In viewCat.inc.php there's already a variable being set, $sort_order, which seems like it should be useful. and already being assigned are template variables based on which one we're sorting by... The following already exists: ## create the links for product sorting - need improving later $sort_order = ($_GET['sort_order'] == 'high') ? 'low' : 'high'; switch($_GET['sort_by']) { case 'name': $view_cat->assign('SORT_NAME_SELECTED', ' selected="selected"'); break; case 'price': $view_cat->assign('SORT_PRICE_SELECTED', ' selected="selected"'); break; } I modified it thus: ## create the links for product sorting - need improving later $sort_order = ($_GET['sort_order'] == 'high') ? 'low' : 'high'; echo '[[sort order:' . $sort_order . ']]'; switch($_GET['sort_by']) { case 'name': $view_cat->assign('SORT_NAME_SELECTED', ' selected="selected"'); $view_cat->assign('SORT_NAME_CLASS', $sort_order); break; case 'price': $view_cat->assign('SORT_PRICE_SELECTED', ' selected="selected"'); $view_cat->assign('SORT_PRICE_CLASS', $sort_order); break; } Then, in viewCat.tpl, I created this line: <p class="sortby">sort by <a href="{SORT_NAME}" class="{SORT_NAME_CLASS}" title="{SORT_NAME_CLASS}">name</a> · <a href="{SORT_PRICE}" class="{SORT_PRICE_CLASS}" title="{SORT_PRICE_CLASS}">price</a></p> You'll notice that I also threw in an echo statement to see how that $sort_order variable's looking. It shows up, but the assignments don't seem to work. What am I missing here? Thanks in advance for any help, Jeremy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.