Tag: drupal planet

09 Nov, 15

Default Search API Sorts Per View in Drupal 7

It's been a while since I've written a post here (especially, Drupal-related). But today I have something interesting to share.

There's a module called Search API sorts (https://drupal.org/project/search_api_sorts) that provides custom sorts and a global sort block for Search API. The module itself is ok, but ...

Read now
20 Apr, 15

Happy birthday to me and Devel form debug module to you all

I’m turning 32 today. People love birthdays, to me it’s just another line number in a messed stack trace output (philosophy mode enabled).
Two years ago I released a drupal module called Get form id (deprecated from now on) that does one small task - it tells you any form's id ...
Read now
27 Oct, 14

How To Force Search API To Reindex a Node / an Entity

By default Search API (Drupal 7) reindexes a node when the node gets updated. But what if you want to reindex a node / an entity on demand or via some other hook i.e. outside of update cycle? Turned out it is a quite simple exercise. You just need to ...

Read now
20 May, 14

Adding a custom extra field to entity / node display

I had a case recently, where I needed to add custom data to the node display and wanted this data to behave like a field, however the data itself didn't belong to a field. By "behaving like a field" I mean you can that field at node display settings and ...

Read now
18 Mar, 14

Replacing Menu Item Visibility module with custom "in code" solution

I'm a big fan of fighting with Drupal's inefficiencies and bottlenecks. Most of these come from contrib modules. Everytime we install a contrib module we should be ready for surprises which come on board with the module.

One of the latest examples is Menu item visibility (https://drupal.org/project ...

Read now
26 Feb, 14

Fixing Views' Scroll to Top When You Have a Fixed Header

Drupal Views offers us a cool feature: ajaxified pagers. When you click on a pager, it changes the page without reloading the main page itself and then scrolls to the top of the view. It works great, but sometimes you may encounter a problem: if you have a fixed header ...

Read now
07 Nov, 13

Programmatically Hiding A Fieldgroup On A Node Display in Drupal 7

If you have a fieldgroup in a node, you may want to hide it on some conditions. Here's how to do that programmatically. At first, we need to preprocess our node like this:

  1. /**
  2. * Implements hook_preprocess_HOOK().
  3. */
  4. function MODULE_NAME_preprocess_node(&$variables) {
  5. }

The tricky part starts here, if ...

Read now
29 Oct, 13

Raw username token for Drupal 7

There are situations, when you or other modules alter username via hook_username_alter() and this can change username dramatically: for example, you can alter username into a combination of First and Last Name, etc. Looks nice, but there's a problem, it will alter username into First and Last Name everywhere, even ...

Read now
01 Oct, 13

All DrupalCon Prague 2013 Videos On One Page

If you've missed DrupalCon Prague 2013 or, maybe, you want to relive once again this great party go and see all videos from the event on this page: all DrupalCon 2013 Prague videos. There you'll find 4 days, 7 hours long video material (104 videos)!

Read now
29 Jul, 13

How To Redirect User To Any Page After Login in Drupal 7

There are loads of modules that can do this for you, but why to install one more module if you can do this with one string of code? The best thing is that approach below does a redirection even if you login from user login block.

Just put the following ...

Read now