Skip directly to content
rteijeiro's picture

Drupal 8 Twig template engine

on Wed, 10/16/2013 - 01:06

As you probably know, one of the best new features of Drupal 8 is the new template engine based on Twig and also used by Symfony community.

We will continue improving Bingo module so you can find all example code in the Drupal sandbox for Bingo module

There are some changes that make better creating templates for your module pages but other things are still the same. For example we still have hook_theme:


 * Implements hook_theme().
function bingo_theme() {
  return array(
    // Template for list of bingo participants.
    'bingo_list' => array(
      'template' =>
rteijeiro's picture

Forms & Database in Drupal 8

on Thu, 10/03/2013 - 00:24

In the previous post we learnt how to create a menu link to access our forms so now we will learn how to create those forms. For our Bingo module, we will need two forms, one to add participants to the contest and other to delete participants from the contest.

Let's start with the form to add participants. We need to implement \Drupal\Core\Form\FormInterface and override it's methods. You can take a look at all available methods in core/lib/Drupal/Core/Form/FormInterface.php file. The following code implements our AddForm class:


rteijeiro's picture

First Approach to Drupal 8

on Tue, 09/17/2013 - 01:08

This is my first post about module development for Drupal 8. I will try to demystify that the transition from Drupal 7 to Drupal 8 is hard and painful. Hope you find this posts helpful and you enjoy reading them as I enjoy writing them. Feel free to ask me in the comments but be patience because I receive tons of spam comments ;)

The examples below are based on the Bingo module I have developed for this posts series. You can clone the repository and take a look at the code while you are reading the post.

First of all we should take a look at .info file changes. The .info file now has YAML

rteijeiro's picture

Drupal 7 Field API sample

on Tue, 05/14/2013 - 22:45

Recently I had to create a custom field for a project I am working on. The field was not difficult to implement, it only had to store two values in the database, but I didn't found a sample tutorial for that so I want to share my experience with you.

If you take a look at the Examples module, you can find a sample field that stores one value in the database, but this sample will show you how to store more data. In fact this field will store two values retrieved from The Internet Chuck Norris Database. One numeric value that represents the joke identificatior and a text value that holds the

rteijeiro's picture

Apache Solr 4 Cookbook

on Mon, 03/25/2013 - 19:31

A few days ago I started to read the Apache Solr 4 Cookbook trying to learn more about Solr and apply this knowledge in my Drupal projects development.

The book consist in a bunch of more than 100 receipts improve Apache Solr performance and make it more reliable and also obtain better results in your queries.

At first the book explain how to install Apache Solr with Jetty and Apache Tomcat, nothing new. But it also explains in a chapter how to configure a distributed Solr cluster installation with SolrCloud and ZooKeeper, something really important if you want a highly available and best

rteijeiro's picture

Hacking Apache Solr query

on Wed, 12/12/2012 - 17:40

Surely you will not need to hack the Apache Solr queries when searching in your Drupal site but, if someday you need to do that, here you are the solution.

First of all you must have a Drupal 7 environment with an Apache Solr server configured. You should take a look at this blog post if you need details about the Solr installation and configuration with Drupal 7.

Just when your environment were ready you can create a simple module with a hook_search_api_solr_query_alter for Search API Sorl Search module or hook_apachesolr_query_alter for Apache Solr Search Integration module.

Here you are

rteijeiro's picture

Drupal 7 & Apache Solr in 5 minutes

on Fri, 11/30/2012 - 20:00

In this post I will explain how you can configure Apache Tomcat, Apache Solr and Drupal 7 in about 5 minutes, taking into account that you have Drupal 7 installed in a Linux based server.

The first step is to install the Tomcat server if you have not already installed it:

aptitude install tomcat6 tomcat6-admin tomcat6-common tomcat6-user

Let's start the server and verify that works:

/etc/init.d/tomcat6 start

Next step is to download the Apache Solr Search Integration module for Drupal 7:

drush dl apachesolr

Now we can install Solr following the Apache Solr module README.txt. As it suggests

rteijeiro's picture

Drupal 7 Custom Field Formatter

on Fri, 11/16/2012 - 21:38

If you want a custom field formatter for an existing drupal field you only need a few lines of code to make it done.

The hook we are going to use are: hook_field_formatter_info and hook_field_formatter_view

In hook_field_formatter_info we will declare the new formatters for the existing field. For example these are four new formatter for the link field:

 * Implements hook_field_formatter_info().
function easythumb_field_formatter_info() {
  return array(
    'easythumb_small' => array(
      'label' => t('Small screenshot'),
      'field types' => array('link_field'),
rteijeiro's picture

Drupal Responsive Theming Basics

on Fri, 10/05/2012 - 19:41

In this post I will try to explain some basics about Drupal Responsive Theming.

I am using the highly configurable Omega theme for responsive theming in Drupal because it has both XHTML and HTML5 starter kits based in fully responsive 960 grid system.

The first step to develop our responsive theme is to download the Omega theme and the Omega Tools module. It will be easily done with drush:

drush dl omega omega_tools

And also we can enable the theme and the module with drush:

drush en omega omega_tools

The next step is to create our subtheme of Omega because we don't want to change the base

rteijeiro's picture

Drupal website in 5 minutes

on Thu, 09/27/2012 - 18:09

I will try to explain how to install a Drupal 7 website in 5 minutes using Drush, an awesome php tool that will help us the tedious work of downloading and installing drupal and the modules needed.

First we must install drush in our system, just following the drush documentation explained in the drush module page.

The next step is to download Drupal 7 from the command line usign the recently installed drush script. Just type the following command to download the latest version of Drupal 7:

drush dl drupal-7

Now we will install the Drupal standard profile and automatically create the