OxyScripts.com
Menu spacer Home Tutorials Articles Code Forums irc.freenode.net #oxyscripts
Main (PHP)
Home Forums PHP News PHP Tutorials Articles PHP Code Snippets Contact Us Sysadmin Resources Books Template Shop
3rd Party Streams
SlashDot PHPDeveloper.org PHP.Net
Resources
PHP Manual MySQL Manual Smarty Manual PEAR Manual PHP-GTK Manual Symfony Manual
Code Snippets
Authentication Database Graphics HTTP Miscellaneous Time/Date
Affiliates
Scripts TutorialMan TutorialGuide CodingForums.com PHP Scripts Cheap Web Hosting Affordable Web Hosting Dreamweaver Templates

Search This Site :     PHP Function Reference :
 

How to display a custom 404 error page

Overview

With symfony, you can easily define a custom error 404 page. You even have several ways to do it.

Introduction

The module and action to be called when a 404 error occurs is defined in the settings.yml configuration file of each application:

all:
  .actions:   
    error_404_module:       default
    error_404_action:       error404

The error404 action of the default module doesn't appear in the application directory, since it is part of symfony.

Solution 1 : change the configuration

You can specify a custom module and action in the settings.yml file:

default:
  .actions:
    error_404_module:       errors
    error_404_action:       error404

Just initialize the new module with:

$ symfony init-module myapp errors

You need to create the action error404 in the file myproject/apps/myapp/modules/errors/actions/action.class.php, and the template error404Success.php in the directory myproject/apps/myapp/modules/errors/templates/. You now have full control over the content of your 404 error page.

Solution 2 : override the default template

A simpler way to do it is to override the default error404Success.php template. It must be located in the default module, so create it if it doesn't exist already.

$ cd myapp/modules
$ mkdir default

Symfony will first look for an action or a template here before calling the default ones. So create a file called error404Success.php in a newly created templates directory, write whatever you need into it, and you're done.

$ cd default
$ mkdir templates
$ cd templates
$ vi "error404Success.php"

Note: Why not use the symfony init-module here? Because it would create an actions.class.php file that would override all the actions of the default default module, including index, login, disabled, secure and unavailable. So using the symfony init-module command would imply erasing the newly created actions.class.php file to focus only on the template.

 
   Print this page

Top Sponsor
Symantec\'s Norton SystemWorks 2006
Sponsors
CA
Sponsors
AdWords Dominator 125*125
Advertisting


Affiliates
VertexTemplates PHPFreaks CodeWalkers StarGeek DevScripts CGI & PHP Scripts PHP CMS Free Templates

Shopping Rebates   Sell It 4 You   Flash Page Counters   Get Insured
GPS Tracking Service   Charity Donate Info   Web Site Hosting   VOIP Service

Privacy Policy | Links | Site Map | Advertising

All content on OxyScripts.com is (©)2002-2007

 
Powered by Adrastea - Version 1.0.0. Copyright © Rune Solutions, 2004-2005