1. New arrivals >>> "Awesome" JA Social Preview! - "Awesome" JAT3 Videos 06 videos!

+ Reply to Thread
 
Results 1 to 10 of 10
  1. #1

    JoomlaTemplate Club Member - Personal License - 1 Year Expired
    anisjolly's Avatar
    Join Date
    Apr 2008
    Location
    Manchester, UK
    Posts
    660
    Points
    0.55
    Downloads
    67
    Uploads
    0
    Thanks
    31
    Thanked 101 Times in 83 Posts
    Please login to vote

    Customized / Branded Error (404) Page - Joomla Hack

    Do you hate it when you have broken links on your site or that dreaded error page with the 404 message appears and it looks nothing like your website???

    Well, today you're going to learn how you can change all that by simply editing one piece of code in your Joomla site.

    For an example of what i'm talking about - just visit one of my sites (links in the signature) and at the end of the URL - just add some text to try and break my site - don't worry all is in order - i'm pretty sure you won't see the joomla error message. Once you've done that - return back here to continue with the modification tutorial.

    To help you with this, I'm going to share with you my own error page and I'll highlight the code below you need to change in order to customize your 404 page.

    But before we start doing this, you need to create an article in the article manager. Call it whatever you want and put in whatever message you want your visitors to see when they come across the broken link / error page.

    Make sure you publish it the the Uncategorized section and category.

    Once you've done that - download my own error page (linked below) and then change the following code in the file you've just downloaded:

    /* Custom Error Page Mod Code */
    if (($this->error->code) == '404') {
    echo file_get_contents('PUT URL FOR YOUR NEWLY CREATED ERROR ARTICLE HERE');
    }
    else
    {

    Your URL for your error article would look something like: http://www.anisjolly.co.uk/index.php...=article&id=66 (if you've not setup SEF etc). If you have SEF enabled you'll need to figure out the URL.

    Ok, we've nearly finished. Once you've done the amendment in the file, upload this amended file to the following folder in your joomla site:

    templates/system/

    It's as simple as that - you're all done. to test out the error page - just do what you tried to do on my site and see if your custom error page works!

    If you have any problems or would like me to do this for you - just leave a message below in this thread or send me a pm and i'll be happy to help.
    Attached Files
    Don't forget to thank people when they've helped you! - click on the Thank You button!
    If your problem has been solved find the best answer and click (Mark Best Answer)

    Voice Of Bolton - powered by JA Opal | Anis Jolly - powered by JA Uvite

  2. The Following 5 Users Say Thank You to anisjolly For This Useful Post:

    gray (02-12-2010), jsliao (02-27-2009), power_on (02-14-2010), questbg (02-27-2009), scotty (02-27-2009)

  3. #2
    Licensed Member Expired
    Joomla Developer Membership - 1 year Expired
    jsliao's Avatar
    Join Date
    Apr 2008
    Location
    Singapore
    Age
    30
    Posts
    792
    Points
    10,184.10
    Downloads
    357
    Uploads
    0
    Thanks
    23
    Thanked 226 Times in 210 Posts
    Please login to vote
    Well technically, sites should never encounter 404 errors if it was well built but mistakes happens and its definately nicer to have a page like this than the default 404 error page.

    Great tip! Bookmarking this one!
    Please click "Thank You" or [Donate] some credits if someone helped you.
    If your problem has been solved find the best answer and click "Mark Best Answer"

    Give a man a fish and he will eat for a day. Teach him how to fish, and he will sit in a boat and drink beer all day.

  4. #3
    Licensed Member
    questbg's Avatar
    Join Date
    May 2008
    Location
    Kotel, Bulgaria
    Posts
    1,877
    Points
    10,569.91
    Downloads
    29
    Uploads
    0
    Thanks
    139
    Thanked 344 Times in 315 Posts
    Please login to vote
    Cheers anisjolly, awesome! I'm on it now
    www.questbulgaria.com - now powered by JA Telline III | www.britishlionfoodstore.com - powered by JA Mesolite
    www.bulgariannorthwestproperties.com - powered by JA Pyrite | Fluency School - powered by JA Nickel

  5. #4
    Super Moderator
    bennitos's Avatar
    Join Date
    May 2008
    Location
    Holland
    Posts
    1,707
    Points
    20,800.69
    Downloads
    174
    Uploads
    0
    Thanks
    38
    Thanked 475 Times in 430 Posts
    Please login to vote
    Nice one anisjolly,

    If there are users who have 404sef installed then you can do this with 404sef aswell.
    It has a simple editor screen where you can make your custom 404 message, or you can decide that instead of showing a 404 error to direct users to a existing article like your frontpage.

    On your 404sef control panel go to the main tab and look for "404 Page"
    Also look at the "404 page" tab where you can use the editor to create a custom msg.
    Please click the "Thank You" button if a post was helpful.

    If your problem has been solved find the best answer and click (Mark Best Answer)

  6. #5
    Licensed Member

    Join Date
    Sep 2009
    Posts
    444
    Points
    5,521.45
    Downloads
    36
    Uploads
    0
    Thanks
    17
    Thanked 168 Times in 140 Posts
    Please login to vote
    Very useful topic! I'm also thinking about creating an custom 404 page.
    BTW, here is some addition information http://docs.joomla.org/Custom_error_pages
    Custom 404 Error Pages for Joomla
    Teline III now is being tuned on www.cugp.com.ua

  7. #6
    Licensed Member

    Join Date
    Sep 2009
    Posts
    444
    Points
    5,521.45
    Downloads
    36
    Uploads
    0
    Thanks
    17
    Thanked 168 Times in 140 Posts
    Please login to vote
    So, I've created the custom error page. I followed recommendations by Google and included:
    - home page link
    - Joomla main menu links
    - Joomla search field
    - Google Analytics tracking code

    All this was implemented with error.php and error.css files. Those interested could contact me via PM.
    Custom 404 Error Pages for Joomla
    Teline III now is being tuned on www.cugp.com.ua

  8. #7
    Unlicensed Member
    Join Date
    Jul 2007
    Posts
    4
    Points
    -39.80
    Downloads
    0
    Uploads
    0
    Thanks
    3
    Thanked 1 Time in 1 Post
    Please login to vote
    Woow.

    Thank you for sharing this.

  9. #8


    Join Date
    Mar 2010
    Posts
    1
    Points
    13.00
    Downloads
    0
    Uploads
    0
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please login to vote

    Exclamation Looks promising except for one thing...

    Don't hack the Joomla core code, future updates will overwrite your changes...

    Instead, simply put the error.php file in your chosen template directory. Joomla will find it and use it instead of the default file.

    For example, the new location will be at:
    yourwebsite.com/templates/yourtemplatename/error.php

    This is probably a better way of doing it...
    http://docs.joomla.org/Custom_error_pages

    I do have a question- how do you add the 404 error page (or whatever your article is called) without adding a menu item?


    skydebaun.com

  10. #9


    Join Date
    Sep 2010
    Posts
    1
    Points
    4.64
    Downloads
    0
    Uploads
    0
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please login to vote
    Quote Originally Posted by anisjolly View Post
    Do you hate it when you have broken links on your site or that dreaded error page with the 404 message appears and it looks nothing like your website???

    Well, today you're going to learn how you can change all that by simply editing one piece of code in your Joomla site.

    For an example of what i'm talking about - just visit one of my sites (links in the signature) and at the end of the URL - just add some text to try and break my site - don't worry all is in order - i'm pretty sure you won't see the joomla error message. Once you've done that - return back here to continue with the modification tutorial.

    To help you with this, I'm going to share with you my own error page and I'll highlight the code below you need to change in order to customize your 404 page.

    But before we start doing this, you need to create an article in the article manager. Call it whatever you want and put in whatever message you want your visitors to see when they come across the broken link / error page.

    Make sure you publish it the the Uncategorized section and category.

    Once you've done that - download my own error page (linked below) and then change the following code in the file you've just downloaded:

    /* Custom Error Page Mod Code */
    if (($this->error->code) == '404') {
    echo file_get_contents('PUT URL FOR YOUR NEWLY CREATED ERROR ARTICLE HERE');
    }
    else
    {

    Your URL for your error article would look something like: http://www.anisjolly.co.uk/index.php...=article&id=66 (if you've not setup SEF etc). If you have SEF enabled you'll need to figure out the URL.

    Ok, we've nearly finished. Once you've done the amendment in the file, upload this amended file to the following folder in your joomla site:

    templates/system/

    It's as simple as that - you're all done. to test out the error page - just do what you tried to do on my site and see if your custom error page works!

    If you have any problems or would like me to do this for you - just leave a message below in this thread or send me a pm and i'll be happy to help.
    this is an other solution, replace all content of system/error.php with this
    <?php
    // no direct access
    defined( '_JEXEC' ) or die( 'Restricted access' );

    /* Custom Error Page Mod Code */
    $urlLink=JURI::base()."/index.php?option=com_content&view=article&id=157";
    $timeout=120;
    $CR = curl_init();
    curl_setopt($CR, CURLOPT_URL, "$urlLink");
    curl_setopt($CR, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($CR, CURLOPT_TIMEOUT, $timeout);
    $response = curl_exec($CR);
    curl_close( $CR );
    $CR=explode("</html>",$CR);
    echo $CR[1]."</html>";
    ?>

  11. #10


    Join Date
    Sep 2010
    Posts
    2
    Points
    4.30
    Downloads
    0
    Uploads
    0
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please login to vote
    It is funny jokes i alway meet 404 for my website. By the way thank you for sharing this.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts