Display Advanced Search on ‘Page Not Found’ page in Zen Cart


Providing the ability to seach your store directly from the ‘Page Not Found’ page can encourage your visitor to stick around and try again, rather than click the back button and go straight to another store.  Any steps you can take to assist in mitigating the effect of a ‘Page Not Found’ page helps both potential customers as well as your bottom line.

To display the advanced search form on the ‘Page Not Found’ page:

  1. Open the tpl_page_not_found_default.php file located in the includes/templates/template_default/templates/ directory.
  2. Find the section of code that calls the ‘page not found’ define text:
    <?php
    /**
     * require the html_define for the page_not_found page
     */
     require($define_page); ?>
    </div>
    <?php } ?>
  3. Immediately following, insert this block of code to call the Advanced Search page:
    <?php require($template->get_template_dir('tpl_advanced_search_default.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_advanced_search_default.php'); ?>
  4. Save the modified tpl_page_not_found_default.php file to your override folder.  This will be includes/templates/CUSTOM/templates/ where CUSTOM represents the name of your current template folder.
  5. Next, we need to ensure that the required language defines are included in the Page Not Found page language file.  Open the page_not_found.php file located in the /includes/languages/english/ directory.
  6. Right before the ?> at the end of the file, insert the following language defines:
    define('NAVBAR_TITLE_1', 'Advanced Search');
     define('NAVBAR_TITLE_2', 'Search Results');
    
     define('HEADING_TITLE_1', 'Advanced Search');
     define('HEADING_TITLE_2', 'Products meeting the search criteria');
    
     define('HEADING_SEARCH_CRITERIA', 'Choose Your Search Terms');
    
     define('TEXT_SEARCH_IN_DESCRIPTION', 'Search In Product Descriptions');
     define('ENTRY_CATEGORIES', 'Limit to Category:');
     define('ENTRY_INCLUDE_SUBCATEGORIES', 'Include Subcategories');
     define('ENTRY_MANUFACTURERS', 'Limit to Manufacturer');
     define('ENTRY_PRICE_RANGE', 'Search by Price Range');
     define('ENTRY_PRICE_FROM', 'Price From:');
     define('ENTRY_PRICE_TO', 'Price To:');
     define('ENTRY_DATE_RANGE', 'Search by Date Added');
     define('ENTRY_DATE_FROM', 'Date From:');
     define('ENTRY_DATE_TO', 'Date To:');
    
     define('TEXT_SEARCH_HELP_LINK', 'Search Help [?]');
    
     define('TEXT_ALL_CATEGORIES', 'All Categories');
     define('TEXT_ALL_MANUFACTURERS', 'All Manufacturers');
    
     define('TABLE_HEADING_IMAGE', '');
     define('TABLE_HEADING_MODEL', 'Model');
     define('TABLE_HEADING_PRODUCTS', 'Product Name');
     define('TABLE_HEADING_MANUFACTURER', 'Manufacturer');
     define('TABLE_HEADING_QUANTITY', 'Quantity');
     define('TABLE_HEADING_PRICE', 'Price');
     define('TABLE_HEADING_WEIGHT', 'Weight');
     define('TABLE_HEADING_BUY_NOW', 'Buy Now');
    
     define('TEXT_NO_PRODUCTS', 'There is no product that matches the search criteria.');
     define('KEYWORD_FORMAT_STRING', 'keywords');
     define('ERROR_AT_LEAST_ONE_INPUT', 'At least one of the fields in the search form must be entered.');
     define('ERROR_INVALID_FROM_DATE', 'Invalid From Date.');
     define('ERROR_INVALID_TO_DATE', 'Invalid To Date.');
     define('ERROR_TO_DATE_LESS_THAN_FROM_DATE', 'To Date must be greater than or equal to From Date.');
     define('ERROR_PRICE_FROM_MUST_BE_NUM', 'Price From must be a number.');
     define('ERROR_PRICE_TO_MUST_BE_NUM', 'Price To must be a number.');
     define('ERROR_PRICE_TO_LESS_THAN_PRICE_FROM', 'Price To must be greater than or equal to Price From.');
     define('ERROR_INVALID_KEYWORDS', 'Invalid keywords.');
  7. Save the modified page_not_found.php file to your override folder.  This will be /includes/languages/english/CUSTOM/ where CUSTOM represents the name of your current template folder.

Now, the ‘Page Not Found’ page in Zen Cart has been customised from this:

Customize the Page Not Found page in Zen Cart

to also include an option to search your online store:

Zen Cart Page Not Found page with Advanced Search

     
   
     

More Zen Cart:

  1. Display a Search Box on ‘Page Not Found’ page in Zen Cart
  2. Display Featured Products on ‘Page Not Found’ page in Zen Cart
  3. How does Zen Cart handle a ‘Page Not Found’?
  4. What makes a great ‘Page Not Found’ 404 Error page for Ecommerce stores?
  5. Change the Search Header in Zen Cart
  1. #1 by Carol on 21 April, 2011 - 10:14 am

    Tried this, but my site seems to forward to the Site Map…it’s not even a “Page Not Found” page. I can’t figure out how to change it. Any ideas?

(will not be published)

Notify me of followup comments via e-mail. You can also subscribe without commenting.