Sunday, February 24, 2013

Handling 'Page Not Found' Errors in BB2

A new config setting in BlueBox2.0 allows for bespoke handling of 'page not found' errors.

This is not to be confused with traditional server-side 404 errors, and only applies to /?page_name allocations withing the BB2.0 database templates engine.

In this case, if you wanted to create a new BB2.0 'page' in the template engine, this would be assigned a page_name.page title in the database templates module. To access your page you would use '/?page_name' and this would then call the page commands contained therein.

Up till recently, if page_name.page did not exist, the fail-over response in BB2 was to attempt to load /?class=page_name and if that failed it would revert to /? (the home page).

So, this new setting, found in the config file (admin->config) is called $system_default_no_page_found, and it take a setting as a string with the class_name:method_name to run in the event that /?some_url is not verified using the above 2 standard methods.

For example, you could set it to run 'bb_come_class:some_method' and it would be invoked as such.

This new approach is very handy in 'url friendly' sites where you want the user to be interpreted based on it's contents. So a user like '/?Run Report One' would then be able to be parsed and run a specific report, or '/?plumbers_in_london' could be parsed to show filtered results.

1 comment:

  1. Hey Paulie, cool post....except I haven't a cooking clue what you just said in your post:)
    That is why you are brilliant at what you do friend.
    Well done and be blessed boet.
    D

    ReplyDelete