Custom 404 Error Page + sh404SEF

  • Posts: 27
  • Thank you received: 2
3 weeks 1 day ago #312338

-- HikaShop version -- : 4.0.0
-- Joomla version -- : 3.9.12
-- PHP version -- : 7.2

Hello,

My site uses sh404SEF but I have disabled it for Hikashop using the "By Component" setting, leaving it to Joomla router. This solution has been suggested by both extensions for optimal performance. This has mostly been a success.

I am wondering about handling 404 errors & showing an error page. If I test by making up a non-existing URL it just shows the system message heading "Warning" with a message "Page not found: abcdefg"

This is not the sh404SEF error page, nor is it Joomla's typical 404 page with the red title bar & "article not found" or "component not found" message. Is there something happening with HikaShop with it's SEF handling?

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

  • Posts: 67389
  • Thank you received: 9992
  • MODERATOR
3 weeks 22 hours ago #312356

Hi,

This is not linked to HikaShop. That page is normally displayed by your template. And you can customize it in your template:
docs.joomla.org/Custom_error_pages

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

  • Posts: 27
  • Thank you received: 2
2 weeks 2 days ago #312577

Hi Nicolas, thanks for your reply. But it is not the Joomla error page or a custom error page.

Eventually, I will set up a custom error page. But I have not put any error.php file in my template yet, and I can't get the Joomla system one to show. When I make up a page URL that doesn't exist, it should show the "system" error page. Like this:



Instead, it looks like HikaShop is trying to find a product or page, and shows my real template, with a simple system message.


It still loads the template, modules, etc. which looks better than the system one. But I am not sure how to stop this from showing, so I can set up the error page how I want, with more useful messaging to visitors.

Attachments:

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

  • Posts: 67389
  • Thank you received: 9992
  • MODERATOR
2 weeks 1 day ago #312588

Hi,

You're supposed to get a standard 404 page when you get that error.
This was added in HikaShop 2.6.4
If you don't get a standard 404 page, then it's probable that you have a view override of product / show.php via the menu Display>Views based on a version of the view file from before the 2.6.4
So please check on that.

If you look at the code there, you'll see this near the beginning:

if(empty($this->element)) {
	if($this->config->get('404_when_product_not_found',1)){
		throw new Exception(JText::_('PRODUCT_NOT_FOUND'), 404);
		echo '</div>';
		return;
	}
	$app->enqueueMessage(JText::_('PRODUCT_NOT_FOUND'));
	hikashop_setPageTitle(JText::_('PRODUCT_NOT_FOUND'));
	echo '</div>';
	return;
}

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

  • Posts: 27
  • Thank you received: 2
2 weeks 1 day ago #312619

Hi Nicolas, thanks for looking further.

I did not have an override for the product / show. But I checked it and compared the code, it looks slightly different - here's what mine contained, without any override (strange!):

if(empty($this->element)) {
	if($this->config->get('404_when_product_not_found',1)){
		header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found", true, 404);
		$app = JFactory::getApplication();
		$app->enqueueMessage(JText::_('PRODUCT_NOT_FOUND'), 'error');
		echo '</div>';
		return;
	}
	$app->enqueueMessage(JText::_('PRODUCT_NOT_FOUND'));
	hikashop_setPageTitle(JText::_('PRODUCT_NOT_FOUND'));
	echo '</div>';
	return;
}

I created an override and replaced it with your code snippet, and it showed the system error page. I then enabled my custom error page and it showed. Curious that my unchanged "show" template had different code. I'd be interested in why but this change did solve the problem. Thanks!

The following user(s) said Thank You: Mohamed Thelji

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

Time to create page: 0.071 seconds
Powered by Kunena Forum