Tag Archives: template

Change default Joomla 404 behaviour or style

To show custom 404 page or redirect user on some error to home page or somewhere else copy file error.php located under /templates/system/ into youre template folder eg /templates/mytemplate/error.php.

For example to redirect user on 404 add these lines right after defined( ‘_JEXEC’ ) or die( ‘Restricted access’ );. This works for Joomla 1.5.

if ( $this->error->code == '404' )
{
	header('http://www.google.com');
	exit;
}

For Joomla 1.6 and 1.7 use

$this->error->getCode() == 404

Of course you can just change style and html of the same file. This is just example for the case you want to redirect user to another page and dont want them too see 404 at all or to add some other custom logic.

Drupal template suggestions

To find out possibilities for naming template files add following line to related template hook in your template.php eg THEME_preprocess_HOOK():

print_r($variables['theme_hook_suggestions']);

Some hooks to look at _html, _page, _node, _block, _pane, _views_view_field, _comment, _search_result, _search_results, _user_profile.

Disable wordpress core updates display

Ever had a situation where you have given admin right to the client?  What usally happens is that client will update the wordpress core. If we are talking about custom solutions, its most definitely not safe to update the core. Here’s a solution for disabling  the opportunity to update WordPress core.

add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );

# 2.8 to 3.0:
remove_action( 'wp_version_check', 'wp_version_check' );
remove_action( 'admin_init', '_maybe_update_core' );
add_filter( 'pre_transient_update_core', create_function( '$a', "return null;" ) );

# 3.0:
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );

XHTML SEO friendly sample header

Standard solution for developing WordPress header. SEO friendly and can be copied every time new template is created.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title><?php wp_title('|', true, 'right'); ?> <?php bloginfo('name'); ?></title>
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php wp_head(); ?>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/img/styles.css" media="all" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/img/styles_screen.css" media="screen, projection" />
<link rel="shortcut icon" type="image/ico" href="<?php bloginfo('stylesheet_directory'); ?>/favicon.ico" />
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/scripts.js"></script>
</head>