On the surface, one of the draw backs of Concrete5 (or
any CMS for that matter) is that there are portions of your site that
seem untouchable. Specifically in Concrete5 the 'Login' page the
'Register' page and the '404 - Page Not Found' are glaring examples of
when the CMS seems to take over your design and returns pages that are
based off the native dashboard theme of Concrete5 and not your own
stylish layout.
In this blog what want to take you step by step on how to change your "404 - Page Not Found" page. The benefit of doing this is twofold:
1st - If, God Forbid, someone should find a broken link on your site or simply type the wrong URL the result is a page that looks like it came from your website and not some misplaced step-child that the developer forgot about.
Below is a picture of what the out-of-the-box 404 page looks like:
2nd - According to the Google SEO Manuel, having a well thought out 404 page can actually help increase your search ranking and your user's experience:
In this blog what want to take you step by step on how to change your "404 - Page Not Found" page. The benefit of doing this is twofold:
1st - If, God Forbid, someone should find a broken link on your site or simply type the wrong URL the result is a page that looks like it came from your website and not some misplaced step-child that the developer forgot about.
Below is a picture of what the out-of-the-box 404 page looks like:
2nd - According to the Google SEO Manuel, having a well thought out 404 page can actually help increase your search ranking and your user's experience:
Step 1: locate site_theme_paths.php
To change the 404 page to reflect your custom theme you will need to open the root/config/site_theme_paths.php file. Make sure you DO NOT open root/concrete/config location. In Concrete5, all customizaton should be done in the top level:Step 2: edit the site_theme_paths.php
When you open the file you should see this:
-
<?php
-
-
-
//possible themes: default, core, greensalad, dark_chocolate, dashboard, greek_yogurt.
-
/*
-
you can override system layouts here - but we're not going to by default
-
-
For example: if you would like to theme your login page with the Green Salad theme,
-
you would uncomment the lines below and change the second argument of setThemeByPath
-
to be the handle of the the Green Salad theme "greensalad"
-
*/
-
-
/*
-
-
$v = View::getInstance();
-
-
$v->setThemeByPath('/login', "yourtheme");
-
// $v->setThemeByPath('/403', "yourtheme");
-
// $v->setThemeByPath('/register', "yourtheme");
-
-
*/
Some examples have been given to help you but it can be kind of confusing. So you will need to 'un-comment' line 15 and then add a condition for the 404 page. You your .php file should look like this:
-
<?php
-
-
-
-
$v = View::getInstance();
-
$v->setThemeByPath('/page_not_found', "retro_ryno");
-
-
-
/*
-
you can override system layouts here - but we're not going to by default
-
-
For example: if you would like to theme your login page with the Green Salad theme,
-
you would uncomment the lines below and change the second argument of setThemeByPath
-
to be the handle of the the Green Salad theme "greensalad"
-
-
*/
-
-
/*
-
$v->setThemeByPath('/login', "yourtheme");
-
// $v->setThemeByPath('/403', "yourtheme");
-
// $v->setThemeByPath('/register', "yourtheme");
-
// $v->setThemeByPath('/dashboard', "yourtheme");
-
//
-
*/
NOTE:
the examples indicate that you should put your theme's 'handle' in place of 'yourtheme'. But not all themes are built the same. The handle for our custom theme is: theme_retro_ryno but when we packaged up the theme we put the files in a folder named 'retro_ryno'. What's necessary for this little trick to work is to use your theme's actual folder name which may or may not be your theme's handle. E.G. our themes path looks like this:root/packages/theme_retro_ryno/themes/retro_ryno/ . So we used the theme's actual folder name instead of it's handle.
Your 404 - page not found is now styled according to your theme! But, it would be nice to add some features to this to help your users out. a good idea would be to add a sitemap as well as a search function. Good news is that google now offers a 404 search bar that works with your site and the url error to try and offer other solutions. And, adding a SiteMap is pretty simple:
Step 3: customize the 404 - page not found.
- you will first need to copy and paste the , root/concrete/single_pages/page_not_found.php' into your root/single_pages/page_not_found.php. notice we are putting this page in the top level because we want to avoid making changes to concrete5.s core.
- open the new page_not_found.php file that you just created in the top level single_pages folder. and make it look like this:
-
-
-
<h1 class="error"><?php echo t('Page Not Found')?></h1>
-
-
<?php echo t('No page could be found at this address.')?>
-
-
-
<br/><br/>
-
<?php $a = new Area("Main"); $a->display($c); ?>
-
<?php } ?>
-
-
<br/><br/>
-
-
<?php
-
$bt = BlockType::getByHandle('autonav');
-
$bt->controller->orderBy = 'display_asc';
-
$bt->controller->displayPages = 'top';
-
$bt->controller->displaySubPages = 'all';
-
$bt->controller->displaySubPageLevels = 'all';
-
$bt->render('view');
-
?>
-
-
<br/><br/>
-
-
<a href="<?php echo DIR_REL?>/"><?php echo t('Back to Home')?></a>.
You should now have a 404 page not found for your site that is nicely styled and has a hard-coded sitemap that will automatically grow as your site grows.
If you would like to take this a step further...
Step 4: add google 404 help.
this will require you to have some kind of google account. Google offers a 404 widget which can be found in your Webmaster Tools portion of your account. Check to picture below to see the instructions and what's being offered:now, the choice is yours but it would be nice to add the widget above your Sitemap. The end result is really nice. click this link to see it in action:
http://www.rynomediaonline.com/contict/
what I did was mispell 'contact'. the Google 404 Widget detects that what I really wanted was the contact page and so automatically adds 'contact' to the search bar. Below this we have our sitemap in case the user would rather see the site that way.
Enjoy!
No comments:
Post a Comment