Tag Archives: Drupal

Drush – The command line tool for Drupal development

In Drupal development, we spend quite a lot of time on module management.

  1. Browser: Go to the module page
  2. Browser: Copy the download link
  3. Shell: Go to the sites/all/modules directory
  4. Shell: Download the module using the wget command with the copied link
  5. Shell: Extract the module by the tar command
  6. Shell: Remove the extracted archive
  7. Browser: Login to the Drupal instance and go to the module page
  8. Browser: Enable the module

 

A typical Drupal website requires about twenty modules. That means you need to repeat the above tedious steps for twenty times. Besides, you have to move your focus between the browser and the shell prompt.
Continue reading Drush – The command line tool for Drupal development

Drupal 7 – Customize Ubercart invoice email template

You can find the Ubercart invoice email template files @ sites/all/modules/ubercart/uc_order/templates. You could copy and edit the uc-order–customer.tpl.php to fit your needs but you could not select it @ E-mail customer checkout notification > Email an order invoice in Rules. This is because you have to implement the hook_uc_invoice_templates() before the new template is selectable.
Continue reading Drupal 7 – Customize Ubercart invoice email template

Drupal 7 – Pass values from PHP to Javascript

During Drupal development, sometimes we may need to manipulate some server data in Javascript. In this case, we could create a custom module to retrieve the database data and pass it to browser such that we can it it in Javascript.

1. Implement the hook_init().

function <module-name>_init() {
  drupal_add_js(
    array(
      'eureka' => array( // we should use module name for best practice
        'data' => array(
          'Name' => 'ykyuen',
          'Blog' => 'Eureka!',
          'URL'  => 'https://eureka.ykyuen.info/',
        ),
      )
    ),
    'setting'
  );
}

Continue reading Drupal 7 – Pass values from PHP to Javascript

jQuery – Synchronize Text Input

In Drupal Development, very often we will use Views and Views Filter for searching data. For example, I have a content type which has two name fields.

  1. English Name – field_english_name
  2. Chinese Name – field_chinese_name

 

I would like to have a single text input filter which could search for these 2 fields with an Or condition.
Continue reading jQuery – Synchronize Text Input

Run Drupal 7 in Nginx

After so many days we have talked about setting up Nginx, PHP-FPM, MariaDB and some PHP caching. We can now try to run a Drupal instance on them. Before we starts, let me listed out all the previous posts.

 

It’s time to start the Drupal installation.
Continue reading Run Drupal 7 in Nginx