Tag Archives: Drupal Development

Foundation 5 – Execute Javascript/jQuery on breakpoint changed

I am working on a Foundation 5 website and i would like to detect the breakpoint change when the user resize the browser window. Here is a workaround found in the Foundation Forum.

1. Add the following piece of HTML to your website. Since i am working with Drupal 7 with the Foundaiton 5 theme, i just add it to the page.tpl.php in the subtheme.

<!-- For breakpoints checking in js -->
<div id="breakpoints"> 
  <div class="breakpoint-small show-for-small-only" data-size="small"></div>
  <div class="breakpoint-medium show-for-medium-only" data-size="medium"></div>
  <div class="breakpoint-large show-for-large-only" data-size="large"></div>
</div>

Continue reading Foundation 5 – Execute Javascript/jQuery on breakpoint changed

Drupal 7 – Get the field values in Style output in Views

Sometimes we may want to know what the field values inside the $row object in the Views Style output template. This could be done by.

$arr_rows = $view->style_plugin->rendered_fields;
<?php foreach($arr_rows as $key=>$arr_row) : ?>
<?php print $arr_row['field1']; ?>
<?php print $arr_row['field2']; ?>
<?php print $arr_row['field3']; ?>
<?php endforeach; ?>

 

Done =)

Reference: extract views $row values

Drupal 7 – IE fix for Bootstrap 3 theme

Previously i have a post about using Bootstrap 3 theme in Drupal 7.

 

If the website you are building needs IE 8 support, a few hacks has to been done. Please note that using CDN to serve the Bootstrap source files will not work in this case. So you have to use method 1 to serve the Bootstrap source files locally when installing the Bootstrap 3 theme in Drupal as stated here.

1. Copy the system/html.tpl.php from the Bootstrap 3 base theme to your subtheme templates folder.
Continue reading Drupal 7 – IE fix for Bootstrap 3 theme

Drupal 7 – Setup Bootstrap 3 Theme with Gulp for LESS compilation

Got a new responsive site freelance and i would like to try Bootstrap 3 theme in Drupal 7. A little bit confused at the very beginning because the theme has a lot of features and bug fixes ongoing. So the documentation is a bit lacking and i have to make some trials and errors before knowing what to do.

Some Drupal developers may also have problem on compiling LESS. So here i include a gulp script and some NodeJS packages to help.

Assume you have setup the Drupal 7.

1. Download the Bootstrap 3 Drupal theme. The current stable version is 7.x-3.0 which is a bit old and only works with Bootstrap 3.0.x. I am going to use 7.x-3.1 which supports the latest Bootstrap version (v3.3.2 at the moment i write this post). The 7.x-3.1 is still in beta (7.x-3.1-beta2). You could download it from the releases listing page.

2. Extract the Bootstrap 3 base theme to the sites/all/themes folder. You would found the starterkits folder containing the subthemes. as follow. Continue reading Drupal 7 – Setup Bootstrap 3 Theme with Gulp for LESS compilation

Drupal 7 – Write a Drush command which takes arguments input

Previously:

 

So it would be more useful if our drush command could take input arguments. Let’s modify the eureka_drush.drush.inc a bit.

eureka_drush.drush.inc

<?php

/**
 * Implementation of hook_drush_command().
 */
function eureka_drush_drush_command() {
  $items = array();
  
  $items['say-hello'] = array(
    'description' => 'Say Hello to someone',
    'arguments' => array(
      'whom' => 'Someone you want to say hello to. Defaults to "Kit".',
    ),
    'drupal dependencies' => array('eureka_drush'),
  );
  
  return $items;
} 

/**
 * Callback function for say-hello.
 * The function name is drush_<module_name>_<command_in_underscore>
 */
function drush_eureka_drush_say_hello($whom = "Kit") {
  $msg = 'Hello ' . $whom;
  drush_print("\n" . $msg . "\n");
}

Continue reading Drupal 7 – Write a Drush command which takes arguments input

Drupal 7 – Write your first Hello World Drush command

1. Create a new custom module. In this example, the module name is eureka_drush.

2. Create the eureka_drush.info.
eureka_drush.info

name = Eureka Drush
description = Custom drush command example.
core = 7.x
package = Eureka

 

3. Create the eureka_drush.module. Even if you do not have any implementation, leave it with just the PHP open tag.
eureka_drush.module

<?php

Continue reading Drupal 7 – Write your first Hello World Drush command

Drupal 7 – Get path alias by Node ID or Term ID

We did talk about using drupal_lookup_path() to get path alias.

The above function is still working in Drupal 7. We could also use the url() to get the path alias url as well.

// Get the node id path alias
url('node/' . $tid);

// Get the term id path alias
url('taxonomy/term/' . $tid);

 

Done =)

Reference: