Search code examples
x-cart

Customize X-Cart 5 error page


I have a store created on X-Cart, and I want to change/customize the contents of default error/404 page. I am using X-cart 5.3. Any ideas what can be done? TIA


Solution

  • Ankit, if you want to change the default contents of the error page (not 404) or the maintenance page (this page shows while the store is in rebuilding state), you should look at the public folder of your X-Cart installation.

    This folder contains error.html (this page is for admin user), and maintenance.html. Also, public/customer folder contains another error.html (the one that shows to the customers).

    Don't modify these files, because they will be overwritten during the upgrade (replacing with the stock ones). Instead, copy them to another folder or create the entire error page from scratch. After that, modify the etc/config.php file to set the correct paths for the error pages like that (replace the <your_dir> part with your folder with the customized pages):

    ; Error handling options ; [error_handling] ; Template for error pages page = "<your_dir>/error.html" page_customer = "<your_dir>/customer/error.html" ; Template for maintenance pages maintenance = "<your_dir>/maintenance.html"

    Make sure these options are not repeated in the config, if they do - remove the stock ones.

    The 404 page is the different case because it is being rendered by the X-Cart templating engine - Twig. There are two ways to edit its content:

    1. You can modify page heading and text labels. Open the X-Cart admin and go to the Store Setup -> Translations page and click on the link with the labels count across the language you want to edit.

    Search for "Page not found" label, and click on the globe icon near the trash icon to edit all available translations. That is the heading of the 404 page.

    Later on, search for "The requested page could not be found." label and repeat the procedure. This label contains the text of the 404 page.

    Please note that any HTML code will be stripped, use the plain text only.

    1. The second option is to modify the template HTML code. You should be accustomed to editing HTML and Twig languages, you should also have the ThemeTweaker addon.

    Copy the skins/customer/404.twig file to the skins/theme_tweaker/customer/404.twig and edit it with the text editor.

    Rebuild the store at the cache management page afterwards.