Articles in the ‘Drupal’ Category

Page template for node type in Drupal

Tuesday, February 22nd, 2011

Page template for node type in Drupal (at least 6.x) is not part of the core. You need to nimble a little with template. php and add the following code:

< ?php
function themename_preprocess_page(&$variables) {
if ($variables['node']->type != "") {
$variables['template_files'][] = "page-node-" . $variables['node']->type;
}
}
?>

Be careful to correct the $variables according to your naming convention in the themename_preprocess_page function header. Also, in case you didn’t know, you need to replace “themename” with… your theme name…sssh!

You can then create PAGE templates for your node types with the naming: page-node-nodetype.tpl.php.

How to properly save diacritics in MySQL database

Wednesday, January 27th, 2010

To save diacritics in a MySQL database you have 5 steps to follow:

1. Set(create) your database with collation utf8_general_ci;

2. Set(create) your table with utf8_general_ci collation also;

3. Make sure the text fields where you’ll insert diacritics have also the utf8_general_ci collation

4. Convert your string into ‘utf-8′ using any method you like. I recommend using PHP’s multibyte functions

e.g. $my_string = mb_convert_encoding($txt, $charset, mb_detect_encoding($my_string));

where:  $my_string is the string that will be inserted

$charset is thecharset where your diacritics are included.

Check also here the Complete list of Popular character encodings

5. Before the insert query execute this query SET NAMES latin2; (if your diacritics are from one of the latin charsets)

Why I don’t see wysiwyg toolbar in Drupal?

Monday, October 5th, 2009

I had a big problem when I installed and configured Wysiwyg+FckEditor for a Drupal 6.x. site  because “print $closure” was missing from page.tpl.php. – wysiwyg toolbar didn’t appeared at all.

$closure
“Needs to be displayed at the bottom of the page, for any dynamic javascript that needs to be called once the page has already been displayed. ”

http://drupal.org/node/11812

So, if you have dynamic javascripts don’t forget to check if you have “print $closure” in your page.tpl.php.