You are hereBlock

Block


Removing a link from Webform block

If you display your webform as block and then also use Full Node view in block settings, you will have a title that leads to the webform itself. Probably you don't want to do that. But what to override, it's kind of simple, just override node--node_id.tpl.php as this is in the end a node display and remove link from h2 tag. That is all.

PHP block visibilty

To set block visibilty with fine details in drupal 7, you need to install php filter which is part of drupal core but not enabled by default. And then off to write some code. First part of code uses node type to show, in this case hide block for particular content type and in the second, we check url argument, so we hide if for particaler views.

<?php
$return = TRUE;
if ( (arg(0) == 'node') && is_numeric(arg(1)) ) {
$nid = arg(1);
$node = node_load($nid);
$type = $node->type;
if($type == "dentist") {

Drupal 6 to drupal 7 migration tips

However you choose to do a migration from drupal 6 to drupal 7 if you have any complexity in your site it is going to be ugly. Lots of errors and leaps of faith :-).

I choose to do it with drush. So after the drush made what it could do. I tested the site. Not working at all, not even logging in possible. What I did is:

Files: 

Adding menu level value to CSS class

I need to theme a menu so that each level has different class in CSS. This needs to be done over template.php and additional code that adds menu level value to your links.

Here is the code you paste in template.php for drupal 7

function template_menu_link(array $variables) {

$element = $variables['element'];
$sub_menu = '';

if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);

How many modules

Often you can see if drupal site is bloated with modules if you just check how many of them are enabled, you can do this quickly with mysql command.

select name from system
where type = 'module' and status = 1
order by name;

Webform block redirect page

You hate it when webform block redirects to webform page and your visitor loses the page he/she was on when submiting form. Well you can sort this out. Make a form "No redirect (reload current page)" on webform/configure but you also need to go and edit block on block admin screen and add "Show all webform pages in block" that will make it work on the same page and not leave page when you submit.

Enable String Translation for Different Input Formats - Block translation

You want to translate a block but it is not showing, there is a bit hidden setting for this to be enabled, catch it here. Adminster -> Site configuration -> Languages -> Configure - "String translation Tab"

http://eureka.ykyuen.info/2011/08/14/drupal-enable-string-translation-fo...

also refresh all the strings in

../admin/build/translate/refresh tab in languge link, otherwise they wouldn't shop up and you will be pulling your hair out :-)

Display Block for specific Content Type

This is how to do this, choose PHP for block visibility mode and add the code below,
choose in types, array your content type

<?php
$match = FALSE;
$types = array('my_content_type' => 1);
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load(array('nid' => $nid));
$type = $node->type;
if (isset($types[$type])) {
$match = TRUE;
}
}

return $match;
?>

Gmap center and resize when block is collapsed

When you have a problem with google map when hiding or collapsing it within a block you need to do something to fix this. A way to do this is to make gmap block absolute in position and -10000 px in left like

#block-gmap_location-0{
position: absolute;
left: -10000px;
}

and then use jquery to show it with js script

$('#block-gmap_location-0').css("position","relative");
$('#block-gmap_location-0').css("left","0px");

and finally map is fixed and working.

Simple google map

You want simple google map without some extra modules, API keys etc? This is rather simple, all you need is to go to google maps, choose your location and go to upper right corner where is "Paste HTML to embed in website" code, copy that code. Go to Block sections in your drupal administration, create new block and place that code in block. Use Full HTML input format so all html can pass and there you go, you will have a block with a map. You can edit width and hight in code, edit lable below it and customize it to your needs. Same way you can do with all other maps like BING etc.