Thursday 14 October 2010

Playing with your Drupal web sites logo and slogan

Hi,

Kind of working on with aisc.com web site today and looking around for some interesting solutions, suddenly I,ve got an idea or actually I needed to find solution for;

How to get Drupal based web sites logo, slogan and other settings in a block on your web page?


Well from first point it looked simple, just to do
only, as on your web sites themes page.tpl.php print $logo with in img tag or etc.
But what looks easy not always is easy. So, I took a time to discover and here comes result - working example.
Before we/you start, on your Drupal based website go to >> admin/build/block. Create a custom block and set input format to PHP code, once it`s ready in block body paste something like this;

<?php
$settings = theme_get_settings('your theme name');
If (!$settings[toogle_logo] = 0) {
if (!$settings[default_logo] = 0) {
print '<img alt="this is logo" height="73" src="' . base_path() . path_to_theme() . '/logo.png" width="64" />';
}
else {
print '<img src="' . base_path() . $settings['logo_path'] . '" width="64" height="73" alt="this is logo" />'; // this prints out path to you uploaded logo
}
}
// for slogan
$slogan = variable_get('site_slogan', 'null');
if (!$settings['toogle_slogan'] = 0 ) {
if(!$slogan = " ") {
print '

Our cooll site slogan: ' .$slogan .'
';
}
else {
print 'Upsss no Slogan on Site
'; // this is for testing
}
}
// yes image width and heigh is set to my case please adjust to your needs.
?>

Ok This is my example, your should adjust it to your web site needs, settings and requirements.

1 comment:

  1. Yes forgot,

    Instead of using print 'img......
    easier is to use print theme_image()
    here is link to this function
    theme_image.

    ReplyDelete