laanes Posted December 9, 2011 Share Posted December 9, 2011 Hi, I am adding "active_filter", "passive_filter" classes to links based on regex pattern coming from the URL: Line 46: https://github.com/laanes/product_filtering/blob/master/APF_URL.php The function gets called on line 89 in here: https://github.com/laanes/product_filtering/blob/master/boxes/advanced_product_filtering_box.inc.php You can see it in action here: http://www.swanseatimber.co.uk/shop/hafele/brand_281.html by clicking on a category on the left, under the heading "Filter Your Results". The clicked category gets a green background because of the added "active_filter" class. When you click again, it will get "passive_filter" class and the products are not filtered any more. The problem: When moving to other pages by using the pagination at the top of the product results, the class doesn't get added. Therefore, you can't remove the filter because function creating the href on line 72 in here: https://github.com/laanes/product_filtering/blob/master/APF_URL.php and the function clearing all filters on line 100 in here: https://github.com/laanes/product_filtering/blob/master/APF_URL.php both fail. What's interesting - when selecting a filter, moving to the next page, clicking in the browser url bar and hiting enter(hard reload i think?), the problem disappears and you can play with the filters again. I really hope you find a minute to look into it and help me. Quote Link to comment https://forums.phpfreaks.com/topic/252810-adding-active-class-to-link-by-regex-match/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 9, 2011 Share Posted December 9, 2011 To build pagination links, without altering any other existing get parameters, see the code in this post - http://www.phpfreaks.com/forums/index.php?topic=348834.msg1646676#msg1646676 If you need to completely remove any specific key/value (i.e. filter) from a URL, simply unset the corresponding $_GET value before using http_build_query to build any link. See this post for an example - http://www.phpfreaks.com/forums/index.php?topic=346257.msg1634757#msg1634757 Quote Link to comment https://forums.phpfreaks.com/topic/252810-adding-active-class-to-link-by-regex-match/#findComment-1296135 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.