Drupal Dump

Drupal Snippets, Hacks and more....

495 posts since 2011

Views, passing argument from node taxonomy term

This code will be often used if you want to pass current node taxonomy term to view to list some other nodes, for example to have a list of similar nodes, nodes with same term. Choose taxonomy term:ID and write thise code down. We load current nodes data and get term ID from key of term.

Printing out Node Variables nicely

You often have to print out node variables to see what you need to do. There are few ways to do that, before i used Drupal Themer for doing this which is part of Devel module. But this is very slow module and it takes a lot of time to load so i am not using it anymore. You can either use dpm function from devel module to dump something to screen nicely or just using plain old

User imports and Duplicat Emails

When you are importing user with Drupal, you probably do it with user import module, but you'll probably have a list of uses without any email or with duplicate emails, in this module its hardcoded that one email is used per person.

Fastest way to edit files, change CSS etc

Fastest way i found to make small changes on your site is to use FTP program like FileZilla. Then you just go to file you want to edit and click view/edit. File is downloaded locally and opened in your default (or the one you set in FileZilla) editor.

Lightbox2, hiding flash content

Having problem with Flash when using lightbox for overlay? Just add transparency to those flash embed codes and they will be in the dark.

<param name="wmode" value="transparent" />
<EMBED src="swf.swf" quality=best bgcolor=#FFFFFF wmode="transparent" WIDTH="550" ...

How to print Description under the each Imagefield

So you put description for your images but there are nowhere to be seen? You or your client wants to have descriptions of images under each one. Well you will have to do some theming, in fact you have to create content-field.tpl.php and put it in your theme directory. And the code should be like this

IE stylesheet Limit

There is a "31 stylesheet limit in IE 6 & 7" so sometimes your page will break in this browsers. You will go crayze, asking yourself whats going and, checking CSS and tags.

Node loading, simple variable passing to flash banner

So in previous post with made drupal custom block now lets make custom block with flash banner where data to banner is passed from node that has CCK fields.Make content type with 4 cck text fields, or just use one field, even body can do and then you can manauly manipulate string with PHP, just have some separator in your input.

Custom block

Sometimes you want to customize block more then its available through drupal admin, then you start themeing. Quickest way is to copy default block.tpl.php file and then edit its name to something you want to customize. Lets say we customize block number 4, which is block created with views, then you make your file name like "block-block-4.tpl.php" and then change its content.