Drupal 7

Drupal 7: Ensure HOOK_node_view is not called by search indexing

When using HOOK_node_view() you should take care because when the search (Search API especially) is indexing, this hook is also being called. You can not rely on a user displaying the node display currently. Here's a way to ensure this...

  1. function MYMODULE_node_view($node, $view_mode, $langcode) {
  2.   if ($view_mode != 'full' || arg(0) != 'node') {

Applying and maintaining Drupal patches efficiently

As Drupal developer you have to mess around with patches sometimes. Some of you might use Drupal module to manage their patches, some may use Git. Others may handle patches manually (which is the worst solution).

Einordnung:

Webhosting mit Drupal als CMS - Anforderungen, Anleitung für den Einstieg

Drupal CMS Logo

Wer Webseiten professionell erstellen und verwalten, aber nicht viel Geld für Software ausgeben möchte, liegt mit Drupal absolut richtig.

Drupal 7 Services 3 Session Authentication with CSRF Token

I really had a bad hour figuring out how Drupal services.module (Version 3.x) session authentication works. The documentation is poor and there are several issues stating out problems.

Finally I was able to find a way out of the Service REST jungle and I'd like to share the results with you (and myself for the future) if we should ever run into the same problems again.

Drupal 7 Commerce: Compare customer profile addresses / check address equality (shipping / billing)

I had the requirement to check the equality of addresses in customer orders (billing / shipping) and wrote two helper functions for that.

Perhaps you'll run into the same demand one day. Then please leave a comment here and in the original issue I posted on Drupal.org to document your demand for such a solution: See https://www.drupal.org/node/2680997

Thank you!

Attach documents (e.g. Terms and conditions) to Drupal Commerce Message order confirmations

Drupal Commerce Message

Attaching documents like PDFs to Drupal eMails is quite simple. For our specific case we needed to attach PDF documents to Drupal Commerce Message order confirmations.

This can easily be done using the hook below. Simply modify the names and path to the document to attach. That's it!

  1. function MY_MODULE_mail_alter(&$message) {

Dokumente (z.B. AGB,WRB) an Drupal Commerce Bestellbestätigungen anhängen

Drupal Commerce Message attachments

Deutsche Onlineshops / eCommerce-Seiten müssen in der Regel AGB und WRB per E-Mail an Kunden versenden. Dies kann unter Einsatz des commerce_message.module mittels eines Hooks sehr einfach realisiert werden.

So lassen sich Dokumente ganz einfach an commerce_message.module Bestellbestätigungen z.B. als PDF anhängen. Natürlich funktioniert dies auch für beliebige andere Dokumenttypen.

Snippet: Drupal 7 render view in code and hide if empty results

Use this simple snippet to embed a view in code and only display it if the view has at least one result (prevent rendering empty views markup):

  1. $view = views_get_view('your_view_name');
  2. $view->set_display('your_view_display');
  3. // Only display the view if it has results and the user has access.
  4. if ($view->access('your_view_display')) {        
  5.         // Example argument

Define extra fields (display) in code for Drupal Commerce products with auto AJAX handling and product+product node types handling

Today I had the challenge to add some extra (programatically calculated) fields to show in commerce.module product display nodes. In our specific case it was a "base price" that should be shown additionally to calculated SALE prices.