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
...fields pending deletion
Cannot disable module - required by Drupal, fields pending deletion.
drush php-eval 'field_purge_batch(10000);'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);Reset my Drupal Admin Password
drush user-password someuser --password="enter-new-password"Not able to login drupal after moving site
if you need to login you can always get a one time login link from Drush:
drush user-login theusernameThe 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 printing a block in a tpl file
Option 1:
$block = block_load('block', '1');
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
print $output;Option 2:
$blockad = module_invoke('views', 'block_view', '4796251df8de94ce18a64f54ef6f2bc4');
print render($blockad['content']);How render the filed value without the wrapper <div>
$node = node_load($nid);
$field = field_get_items('node', $node, 'field_name');
$output = field_view_value('node', $node, 'field_name', $field[$delta]);Get substring between two strings PHP
In this example we are taken the url. The goal is to get the string between 'num-' and '/': 5555555.
http://example.com/content/view/onenodeexample---addtional-data--num-555...
$url = check_plain(request_uri());
preg_match('~m-(.*?)/~', $url, $output);
return $output[1];Note:
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 }