Drupal Dump

Drupal Snippets, Hacks and more....

495 posts since 2011

Sorting array of objects by value

Drupal uses many multidimensional arrays and usually you won't need to do this, or will do it in some theme layer or with views. But I did have a case where I needed to sort out array of entities by score value so I did it this way.

Getting host node and node id of field collection

I was killing myself to get host node and node.id of field_collection I am using so I can do some preprocessing before this node is saved. I was trying with field_collection_item_get_host_entity but just couldn't make it work. So I asked google and found out I can do it with regular host function like

Getting host node and node id of field collection

I was killing myself to get host node and node.id of field_collection I am using so I can do some preprocessing before this node is saved. I was trying with field_collection_item_get_host_entity but just couldn't make it work. So I asked google and found out I can do it with regular host function like

Module paths in DB

Working with multi sites and modules located in sites/all and sites/some_site your module paths could get in problems. So for a fix check you just need to replace paths in your DB like

Drupal Drush Command Cheat Sheet Copy

Everbody likes Drush, why wouldn't you. Anyway I copied cheat sheet from some PDF as this is a drupal dump site and this way I can find it quicker and make also some additions to it.

When available, there is a shorter version of the same command in parentheses.

cache clear (cc) Clear all caches.

cron Run all cron hooks.

Drupal missing modules and white screen of death

WSOD (white screen of death) can happen in drupal for different reasons. One is that you could be missing some files, probably modules. Maybe you moved something wrong when migrating, or you have wrong git branch or just delete module(s).

Reseting passwords in Drupal 7

Reseting drupal password with latest drupal version has become much harder task, before you could just MD5 user table and add new password, now the "salt" is added so it is a bit harder. There are two ways, with mysql and shell access, or with php file. First you can find here

Outside Links collection

Sometimes you find just the right resources that fulfill certain need and nothing much should be added to them, in those cases I will just collect them on this page and add short comment why is this so.