Skip to content

Instantly share code, notes, and snippets.

@metamn
Created May 7, 2011 09:53
Show Gist options
  • Save metamn/960375 to your computer and use it in GitHub Desktop.
Save metamn/960375 to your computer and use it in GitHub Desktop.
Shopify collections get current product type or vendor
// Making the selected product type/vendor active at Collections page
var urlParams = {};
(function () {
var e,
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&=]+)=?([^&]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.search.substring(1);
while (e = r.exec(q))
urlParams[d(e[1])] = d(e[2]);
})();
if (urlParams['q']) {
jQuery(".collection #navigation .jquery-active a").each(function(index){
if (jQuery(this).html() == urlParams['q']) {
jQuery(this).addClass('active');
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment