cannot go to next page when url contains limit

  • Posts: 26
  • Thank you received: 0
  • Hikashop Business
9 years 4 months ago #239029

-- url of the page with the problem -- : www.plcdirect.eu/products/limit-switches/plastic-body
-- HikaShop version -- : 2.6.3
-- Joomla version -- : 3.5.1

When a weblink of our Hikashop store contains the word "limit" directly after a slash it is not possible to go to the next page.

www.plcdirect.eu/products/sensors/proxim...it-switch-style-body
goes to
www.plcdirect.eu/products/sensors/proxim...mit-20?limitstart=20
instead of
www.plcdirect.eu/products/sensors/proxim...mit=20&limitstart=20

www.plcdirect.eu/products/limit-switches/plastic-body
goes to
www.plcdirect.eu/products/limit-20/aluminium-body?limitstart=20
instead of
www.plcdirect.eu/products/limit-switches...mit=20&limitstart=20

When the word "limit" is not present in the url, the next page can be reaced
www.plcdirect.eu/products/industrial-computers/panel-pcs
goes to
www.plcdirect.eu/products/industrial-com...mit=20&limitstart=20


We would like to be able to use the term "limit" in our weblinks and still be able to go to the next page.
How can this problem be solved?

Please Log in or Create an account to join the conversation.

  • Posts: 84311
  • Thank you received: 13701
  • MODERATOR
9 years 4 months ago #239035

Hi,

Thank you for your feedback.
Change the code:

	function addParametersToUrl($url, $parameters){
		foreach($parameters as $k => $v){
			if($v == ' ') $v = '';
			if(strpos($url,$k)!==false){
				if(preg_match('#(\?|\&|\/)'.$k.'(\-|\=)(.*?)(?=(\&|.html|\/))#i',$url,$matches)){
					$url = str_replace($matches[0],$matches[1].$k.$matches[2].$v,$url);
				}elseif(preg_match('#(\?|\&|\/)'.$k.'(\-|\=)(.*)#i',$url,$matches)){
					$url = str_replace($matches[0],$matches[1].$k.$matches[2].$v,$url);
				}
			}else{
				$start = '?';
				if(strpos($url,'?')!==false){
					$start = '&';
				}
				$url.=$start.$k.'='.$v;
			}
		}
		return $url;
	}
to:
	function addParametersToUrl($url, $parameters){
		foreach($parameters as $k => $v){
			if($v == ' ') $v = '';
			if(strpos($url,$k.'-')!==false || strpos($url,$k.'=')!==false){
				if(!preg_match_all('#(\?|\&|\/)'.$k.'(\-|\=)(.*?)(?=(\&|\?|.html|\/))#i',$url,$matches)){
					preg_match_all('#(\?|\&|\/)'.$k.'(\-|\=)(.*)#i',$url,$matches);
				}
				if(!empty($matches) && count($matches)){
					$done = false;
					foreach($matches[0] as $i => $match){
						if(!in_array($k,array('limit','limistart')) || is_numeric($matches[3][$i])){
							$url = str_replace($matches[0][$i],$matches[1][$i].$k.$matches[2][$i].$v,$url);
							$done = true;
							break;
						}
					}
					if(!$done){
						$start = '?';
						if(strpos($url,'?')!==false){
							$start = '&';
						}
						$url.=$start.$k.'='.$v;
					}
				}
			}else{
				$start = '?';
				if(strpos($url,'?')!==false){
					$start = '&';
				}
				$url.=$start.$k.'='.$v;
			}
		}
		return $url;
	}
in the file components/com_hikashop/views/product/view.html.php and that should fix the problem.

Last edit: 9 years 4 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 26
  • Thank you received: 0
  • Hikashop Business
9 years 4 months ago #239319

Hi Nicholas,

thank you for the solution. But... a change in components/com_hikashop/views/product/view.html.php would be a core hack of your extension. Will this solution also be added to a new version of Hikashop? Otherwise every update would kill this override.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
9 years 4 months ago #239321

Hi,

Generally when we give core code modifications, we add the fix on our end and it is in the next releases.
So you can apply the modification, it will be overridden by our code but with the same fix so no issues

Please Log in or Create an account to join the conversation.

Time to create page: 0.071 seconds
Powered by Kunena Forum