You are hereDrupal 6

Drupal 6


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;
?>

Moving site, Server settings and 500 error

Recently I was envolved with moving a site from one server (VPS) to other. I had to make a VPS installation also and setup of the server. I used Debian 6 which usually comes with php 5.3. Sometimes some modules have problems with 5.3 version of PHP. So when i transfered drupal site(drupal 6) I kept getting 500 error on server and tought this was somehow due to 5.3 php and some module i had, as on original location I had 5.2 so i was trying to force 5.2 to this server and lost bunch of time on this.

Authoring information and permissions

User 1 has all the privilegies. But for other you need to set them. If you want that user has ability to change who authored node you will need to give him "administer nodes" permission. Usually overlooked, this permission is unde node module permission set.

Views Arguments validation "Gotcha"

People usually set argument and often don't mind about validation. Just leave basic validation thinking most will pass. But that is not the case. For example you can use User ID ad argument and think both UID and User Name would pass, but that is not the case. You have to go and select "User" Validator and use "Allow both numeric UIDs and string usernames" for this to work. Otherwise you could have a view that is showing nothing and left you wondering what is happening.

CSS in IE8 list tag(LI) in one row

I just encontured stupid problem with IE and listing LI tags in one a row, If you want to list them properly and not skip into second you need to add some
white-space: no-wrap; to work to LI or in fact A tag inside LI. Those having that problem will know what I am talking about.

Theming filters in Views 2.x differently

Most will use views 3.x in future and they should as they are really better, from UI point of view to other parts but for some old sites that are not updated and you want to theme exposed filters differently, you can't from default. You need to change some template as all your filters have the same classes.

Override the exposed form template in your theme -- take a look at /modules/views/theme/views-exposed-form.tpl.php

Change line 25 from <div class="views-exposed-widget">
to

Views Fluid Grid - jQuery Masonry Fix for images

There is a great module currently to simulate pinterest tiles on drupal views. Unfortionatly it's not properly maintaind and most import thing, image tileing is currently not working. So what you need to do is make some fixes, upload latest masonry files and add also jquery.imagesloaded.min.js to /js folder, then change code to already pretty messy integration to views to support imagesloaded js file. Should be changed as its here stated http://masonry.desandro.com/demos/images.html so to do that i changed module file, add to module this

Converting Date timestamp to proper Date

If you have some variable in your node object or somewhere else like [created] = 1328281634 then you need to convert this to date format you like, so you can do it
with line like this, where you choose custom date format

format_date($timestamp, 'custom', 'D, j M, Y \a\\t G:i' );

or use some predefined date format on your site like

format_date($timestamp, 'small');
format_date($timestamp, 'large');

For custom formating look here PHP Date

Imagecache output in template.php

Sometimes when theming on some level you need to output some image through imagecache, so here is how to do it. Usually in some function in template.php you will write this

$node_img = theme('imagecache', 'Nletter', $node->field_naslovna[0]['filepath'], $node->field_naslovna[0]['alt'], $node->field_naslovna[0]['title'], null);

Where "Nletter" is the name of imagecache and "field_naslovna" is the name of the CCK field.

Drupal patching - How to apply patch on Linux

I constantly forget how to properly applay patches to drupal modules and often some patches can be a life saver before official release is made. So if you are on some VPS or Dedicated server, you use your SSH access and go to module directory you wish to patch, then check also if you need to go to this module subdirectory like some "/components" or something, then download file with WGET command from source of the patch, you can copy the source by right clicking on patch and copying location of the link, then just write

patch < name.ofthe.patch