Moved to Gist
Because the editor of tumblr is too bad for code snippets, I moved to Gist.
https://gist.github.com/hanamizuki
KIROKAZE
𓃗
I'd rather be in outer space 🛸
Misplaced Lens Cap

ellievsbear

if i look back, i am lost
hello vonnie
macklin celebrini has autism

titsay
ojovivo

Origami Around

#extradirty
taylor price

No title available
Keni
Lint Roller? I Barely Know Her
YOU ARE THE REASON
d e v o n

gracie abrams

@theartofmadeline
seen from United States

seen from Türkiye
seen from Ukraine
seen from Venezuela
seen from Germany

seen from Australia

seen from Malaysia
seen from United States
seen from Argentina
seen from Brazil

seen from United States

seen from Malaysia
seen from United States

seen from Canada
seen from Colombia
seen from Finland

seen from Indonesia
seen from Thailand

seen from Poland
seen from United States
@miss-hana
Moved to Gist
Because the editor of tumblr is too bad for code snippets, I moved to Gist.
https://gist.github.com/hanamizuki
Granting roles to a user when registering via fboauth
function yourmodule_user_presave(&$edit, $account, $category) { // 'n' should equal the role id. if ($account->is_new && isset($edit['fboauth']) && $edit['fboauth']) { $edit['roles'][n] = TRUE; } }
Kill/Remove Drupal system stylesheets (CSS)
In the .info of your theme, after adding your own css files, add this ; REMOVE THESE DEFAULT STYLESHEETS stylesheets[all][] = ctools.css stylesheets[all][] = field.css stylesheets[all][] = node.css stylesheets[all][] = system.messages.css stylesheets[all][] = system.menus.css stylesheets[all][] = system.base.css stylesheets[all][] = user.css stylesheets[all][] = views.css
An example of config.rb for Sass and Compass
It's an example of [config.rb that you can use in Drupal theme](http://miss-hana.com/using-sass-and-compass-in-drupal-7/). preferred_syntax = :sass http_path = '/' css_dir = "assets/css" sass_dir = 'assets/sass' images_dir = 'assets/images' #javascripts_dir = 'assets/js' relative_assets = true line_comments = true output_style = :expanded #output_style = :compressed
Count a view result
<?php print count(views_get_current_view()->result); ?>
Getting the number of times an item is flagged
Getting the number of times an item is flagged
Whenever an item is flagged, or unflagged, a counter field is updated. To read this counter, use the get_count() method:
<?php $flag = flag_get_flag('votes') or die('no "votes" flag'); print "The number of people who voted for this proposal:"; print $flag->get_count($node->nid); ?>
A different approach is to use tokens. This module provides a count token for each flag, and you can use it in email messages, for example, and in every place that accepts tokens:
<?php Hello, [node-author]. Your post has been bookmarked [flag-bookmarks-count] times. ?>
A different method, get_user_count(), is used for counting the items a user has flagged. This method is less efficient than get_count() because an SQL COUNT query is issued.
$flag = flag_get_flag('votes') or die('no "votes" flag'); // We assume an $account variable exists in this template. print format_plural($flag->get_user_count($account->uid), 'This user has participated in 1 voting.', 'This user has participated in @count votings.');
Common drush commands for Migrate 2
Deregister migrate classes which is not exist:
drush migrate-deregister --orphans
Other common commands:
migrate-audit (ma) View information on problems in a migration.
migrate-deregister Remove all tracking of a migration
migrate-fields-desti List the fields available for mapping in a destination.
migrate-fields-sourc List the fields available for mapping from a source.
migrate-import (mi) Perform one or more migration processes
migrate-mappings View information on all field mappings in a migration.
migrate-reset-status Reset a active migration's status to idle
migrate-rollback (mr) Roll back the destination objects from a given migration
migrate-status (ms) List all migrations with current status.
migrate-stop (mst) Stop an active migration operation
migrate-wipe (mw) Delete all nodes from specified content types.
Render a block programmatically
Drupal 6:
<?php
$block = module_invoke('MODULE_NAME', 'block', 'view', MODULE_DELTA);
print $block['content'];
?>
Drupal 7:
this will print with title
<?php
$block = block_load('locale', 'language');
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
print $output;
?>
this will print without title
<?php
$block2 = module_invoke('locale', 'block_view', 'language');
print render($block2['content']);
?>
Ref:
http://api.drupal.org/api/drupal/includes!module.inc/function/module_invoke/7
Get base path of Drupal installation
Two ways,
<?php
print '$base_path';
print '$GLOBALS[base_url]';
?>
ROBOTS OR DINOSAURS?
An innocent girl.
t function with context
t();
http://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/t/7
An example of using context.
<?php
print t(‘TEXT TO BE TRANSLATED’, array(), array(‘context’=>‘CONTEXT NAME’));
?>