Our site www.viart.com site is operated by latest Viart Shop 5 with default Clear design
Topic Information
arkid
arkid
Hi all
 
Something I couldn't quite believe still doesn't exist is a proper 404 handling system within Viart. I find it quite worrying when Viart ends up on a simply empty white page if for any reason a user ends up at a page that doesn't exist and I've always felt the need to improve on this for my clients.
 
To resolve this you can customise the friendly_url.php page in various ways. I normally add my own "custom page" in the Viart CMS called "404" and then make the friendly_url.php redirect to that.
 
 
I had a discussion with Vera about this today and he confirmed a few different methods they had used before. So to quote him rather than me....
 
 
Find the following block in the script
--------------
} else {
$is_friendly_url = false;
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
exit;
}
--------------
and replace it with something like this:
 
--------------
} else {
$is_friendly_url = false;
$file404 = "404.shtml";
echo "404 error: Page not found.";
exit;
}
--------------
Your empty page will display the echoed message.
If you wish to show some file there (eg. 404.shtml),
please try the following code instead:
--------------
} else {
$is_friendly_url = false;
$file404 = "404.shtml";
if(file_exists($file404)) {
$echo_string = implode("",file($file404));
} else {
$echo_string = "404 error: Page not found.";
}
echo $echo_string;
exit;
}
--------------
Last modified: 5 Jan 2011 10:33 AM
 
Ibn Saeed
Ibn Saeed
Thanks alot arkid
 
This will definitely come in use
 
arkid
arkid
For the perfect 404 page I think the not found message returned to the user should suggest pages to you. This then gives them a lead on where to go in the site and not just leave them lost and having to return to the homepage or via a random navigation link in your menu/header.
 
And the best way of doing this (IMHO) is suggesting not just a fixed list of say the core pages in the site (although it could do this as well as what im about to say) but to suggest a dynamic list that is even similar to what you typed. In the case of simply entering a typo url this is exactly what the user would want and may prompt them with the page they actually wanted.
 
 
Doing this is an extension to what I have already written really. I would create a custom full page in the viart cms (as mentioned before) and specify that it loads its content from a local php file.
 
 
In that php file I would then capture the previous page url and write a routine that uses PHPs levenshtein (http://php.net/manual/en/function.levenshtein.php) algorithm to search the friendly_url column of the viart "va_pages" and "va_items" tables. You could then add all the results into an array and enumerate through them comparing the captured page friendly url with the urls of all the sites actual friendly urls.
 
You would then output to screen the closest matches to offer a really friendly 404 page that is suggesting close matches to what you typed.
Last modified: 8 Jan 2011 4:04 PM
 
Ibn Saeed
Ibn Saeed
@arkid, are you going to upload the php file for the community ?
 
arkid
arkid
I havent written the php file... i was just thinking aloud and if i do it down the road for a customer I will.
 
arkid
arkid
custom_404.php.txt (6Kb)  
ibn saeed; I have now written this for a new customer and I am able to share this. Feel free to play around with it if its of use!? I have it running on my new site currently in development and its working quite well.
 
arkid
arkid
Capture.PNG (100Kb)  
Here is a shot of the custom content being written into the viart page I made called "404". You can see from the address bar in the shot that I had previously requested a url called "aboutz us" and it has correctly suggested at the top of the list that I may be after the "About" page.
Last modified: 17 Jan 2011 1:03 PM
 
arkid
arkid
I would add that anyone wanting to use the code may want to add to the 2 SQL statements the following to the end..
 
..." WHERE is_showing = 1"
 
Which will ensure that pages and products returned are only ones that have been set live in the shop.
 
Ibn Saeed
Ibn Saeed
Thanks, excellent.
 
Ill give it a try on my local test site.
 
Haider
Haider
|̲̅̅●̲̅̅|llılılı.....Thanks for Sharing ... Happy Holidays ........ılılıll|̲̅̅●̲̅̅|