You are here:  » Sort By Drop Down


Sort By Drop Down

Submitted by tisbris on Wed, 2013-05-08 22:42 in

Hello David

I'm in trouble again...

I try to implement a dropdown for Sort By: Relevance, Price....

I got this:

      $sortOptions = array(relevance,priceAsc,priceDesc);
// $sortOptions = $titleSort;
      $sortForm = "<form method='GET' style='display:inline;'>";
      $sortForm .= "<input type='hidden' name='q' value='".htmlentities($q)."' />";
      $sortForm .= "<input type='hidden' name='sort' value='".htmlentities($sort)."' />";
      $sortForm .= "<select name='sort' class='span2' onChange='this.form.submit();'>";
      foreach($sortOptions as $w)
      {
        $selected = (($sort == $w)?"selected='selected'":"");
        $sortForm .= "<option value='".$w."' ".$selected.">".$w."</option>";
      }
      $sortForm .= "</select>";
      $sortForm .= "<noscript><input type='submit' value='Change' ></noscript>";
      $sortForm .= "</form>";
      $banner["h5"] .= $sortForm;

but it do not work all the time.

Do you already have e dropdown mod for sort by?

//Brian

Submitted by support on Thu, 2013-05-09 09:09

Hello Brian,

The only problem I can see is that you have this line:

      $sortForm .= "<input type='hidden' name='sort' value='".htmlentities($sort)."' />";

...which isn't required as the sort field is coming from your drop-down, so they would be conflicting - that should be all it is...

Cheers,
David.
--
PriceTapestry.com