Drupal Dump

Drupal Snippets, Hacks and more....

495 posts since 2011

Placholders in t('')

This one is easily overlooked but pretty important, strings in translation function can have arguments that can be replaced in 3 ways.

$text = t("This is !name's website", array('!name' => $username));
$text = t("This is @name's website", array('@name' => $username));
$text = t("This is %name's website", array('%name' => $username));

Features: View not displayed in list of components in

I wanted to make 2 features with the same view, but different setting, what was odd was once I had created one, the other didn't list in feature components list. I tried many things but in the end it appears that this is a "feature" of features, a not so nice one I might add.

Importing zip mysql dump

zcat /Users/Marko/Downloads/file.sql.gz | mysql -u 'root' -p'password' your_database

just drop this line in your linux or mac and fill data you need to fill and wait :) or this for gz files

gunzip < /Users/Marko/Downloads/mydb.sql.gz | mysql -u root -p mydb

or for ZIP files

Git logs, find where it went wrong

When I want to find something in GIT and see who and when removed some code I start to search GIT, best command combo is this.

 git log -S "$location['country_code']" -p

For current branch

Truncate all cache tables with drush or code

Drush

echo "SHOW TABLES LIKE 'cache%'" | $(drush sql-connect) | tail -n +2 | xargs -L1 -I% echo "TRUNCATE TABLE %;" | $(drush sql-connect) -v

Here's how to do this from the command line...