You are here

drupal

Drush Cron Already Running Issue

#Fix Cron Already Running Problem
#please replace ?text? appropriately

#log in to mysql from terminal:
mysql -u ?dbusername? -p

#Sequential mysql commands to fix:
------------------------------------
mysql> show databases;
mysql> use ?dbname?;
mysql> DELETE FROM `variable` WHERE name = 'cron_semaphore';
mysql> DELETE FROM `variable` WHERE name = 'cron_last';
mysql> exit
---------------------------------------------------

drush cc all

#Test
drush cron

How to get image url with applied style

$image_uri      = $node->field_image['und'][0]['uri']; // or any public://my_image
$style          = 'my_style';
$derivative_uri = image_style_path($style, $image_uri);
$success        = file_exists($derivative_uri) || image_style_create_derivative(image_style_load($style), $image_uri, $derivative_uri);
$new_image_url  = file_create_url($derivative_uri);

Overriding Page Templates per Content Type in Drupal 7

The process is straightforward. We can create additional Template Suggestions simply by adding them to the ‘theme_hook_suggestions array in our template.php file.

Open the template.php file in your theme for editing.
Look for a function called yourthemename_preprocess_page (replace the yourthemename with your theme’s name).
If this function already exists, you will need to add the if statement to the end of the function just before the closing bracket. Otherwise you’ll need to create a new function to look like this:

How To Add External Fonts (Drupal 8)

NOTE: Important parts here are YOURTHEMENAME.info.yml and YOURTHEMENAME.libraries.yml

YOURTHEMENAME.info.yml

libraries:
  - 'YOURTHEMENAME/fonts'

YOURTHEMENAME.libraries.yml

fonts:
  css:
    theme:
      '//fonts.googleapis.com/css?family=Roboto+Condensed:300italic,400,300,700|Open+Sans:300italic,400,300': { type: external, minified: true }

Pages