Outside Links collection sticky icon

Sometimes you find just the right resources that fulfill certain need and nothing much should be added to them, in those cases I will just collect them on this page and add short comment why is this so.

How to combine Git and Drush to have perfect workflow for site maintenance, information and examples are here

Setting upt perfect Git + Drush workflow, read here

Importing wordpress (ver 3 and 4) users to Drupal 7, how to solve password problem

So importing data from WP is not so hard, you can do it in different ways, mapping data as you need. But what to do about passwords. they are encrypted, WP uses "one-way encryption" and you will need hacker to know what is in them. There are 2 methods.

1. Copy paste

Logging mysql on localhost

In mysql 5.6+. Use this:

general_log = on

in your my.cnf / my.ini file

http-response set-header X-Frame-Options DENY will break AJAX on edit forms

We had on server this thing set
http-response set-header X-Frame-Options DENY

Which in the end made all the ajax form on node edit/add, product edit/add stop working and throwing out errors on browser console.
Refused to display 'https://dev.site.com/system/ajax' in a frame because it set 'X-Frame-Options' to 'DENY'.

So this cant be used that way in drupal.

DB Uploading from local to remote

mysqldump -u user -p databasename > dump.sql

Then using SCP transfer the file to the remote server:

scp dump.sql user@remotehost.ip:

Then use the mysql client there to import the dump.sql with:

mysql -u user_name -p databasename < dump.sql

Ajax error on node add/edit, opened a new browser window instead of file upload or reference edit

One of those things. We have spent 4 hours, 2 persons combined hunting down this problem. Google GTM code, which we for specific reason enabled on node add forms, broke all ajax forms and made crayze problem of opening new browser window instead of editing the node reference field with inline entity form. The same thing happened also on image upload widget. Remove google GTM code from page, solved the issue.

Two ways to change patterns in pathauto

First is to use hook_pathauto_pattern_alter and add some code to it like

function hook_pathauto_pattern_alter(&$pattern, array &$context) {
// Switch out any [node:created:*] tokens with [node:updated:*] on update.
if ($module == 'node' && ($context['op'] == 'update')) {
$pattern = preg_replace('/\[node:created(\:[^]]*)?\]/', '[node:updated$1]', $pattern);

where in context you will find all the date you need to match specific entity and language

Or you can use Variables and make a token out of it and it is i18n aware.

Getting product display info from product ID and building node object with only needed fields

So we make query to get node ID from particular product ID

$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'node', '=')
->propertyCondition('type', 'product_display')
->fieldCondition('field_product_reference', 'product_id', '1092', '=')
->range(0, 1);

If node is present, we do the array building

if ($result = $query->execute()) {

$nodeview = $result['node'];

// At first we need to get field's id. If you already know field id, you can ommit this step

Encoding PHP array to JSON, how to encode square brackets []

To make square brackets in JSON, which is basically array in JSON you need to write array twice. So make it

$data = json_encode(array(
'list'=>array(array('commerce_price_aud' => array (....

RESTws using PHP-CURL to update or add data. Loging in and authentication

Although there is an article here about it http://blog.ampli.fi/creating-drupal-7-nodes-with-php-via-the-restws-api/
I will copy mine code I used to test, just in case.

Things to watch out for is NOT to include JSON suffix, when using CURL

* Update: HTTP PUT //.
or HTTP PUT // (requires HTTP
Content-Type header set to the MIME type of the posted format)

and the hard limit when querying.