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
http://www.jenlampton.com/blog/keeping-your-drupal-site-date-git-and-drush

Setting upt perfect Git + Drush workflow, read here
http://www.acquia.com/blog/using-git-drush-win-workflow

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
array(array('something'....

$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.

theme_debug twig debugging in drupal 7

For some time this has been in drupal 7, ported from drupal 8
https://www.drupal.org/node/2307505

But not really mentioned much. Its a nice feature where you get directly in your html template file names you can use for changing html.
Looking like this

so you done need to DPM and see what is what for each content part, just have it all there. How to activate it?
Just set variable to TRUE

Loading content with AJAX link, anywhere

There are different methods and bunch of modules to ajaxify links in drupal. There are different solutions with code, like this one
https://www.drupal.org/node/2046693
and there are more simple I would add, like this one
http://codekarate.com/blog/drupal-7-javascript-ajax-framework-example-link

I used variation of the codekarate tutorial. To put my AJAX link anywhere. I used template, to be more precise I added a custom form element in rendered array. Like this

$content['helpful-comments'] = array(
'#type' => 'link',
'#title' => t('Most helpful first'),

Custom form, custom template or preprocess function

Having custom template or function to preprocess your custom form in module has few tricks.

First you need to define it in form

$form = array();
$form['#theme'] = 'my_form_theming_function';
....

then define hook_theme

function my_module_theme() {
return array(
'my_form_theming_function' => array(
'render element' => 'form',
),
);
}

and then finally define that theme function in module as

function theme_my_form_theming_function($variables) {
dpm($variables);

Altering weight of elements in arrays used for rendering

When changing weight of element in array, it is not enough to just change weight, #sorted must be set to FALSE so elements are resorted.

$variables['form']['element']['#weight'] = -10;
$variables['form']['element']['#sorted'] = FALSE;

Add title/label to fivestar field in custom form

Took time to find out this one. To set title or label for a fivestar form field you need to add
'#title' => t('Your rate'), to your code, so it should go like.

$pane_form['rating'] = array(
'#type' => 'fivestar',
'#default_value' => 100,
'#title' => t('Your rate'),
'#widget' => array(
'name' => 'some__stars',
),
);

Wondering how to combine drupal with mailchimp content wise - use RSS

Use Mailchimp's RSS-Driven Campaign as it is refered to here. So make a view outputting RSS and use that.

http://kb.mailchimp.com/campaigns/rss-in-campaigns/create-an-rss-driven-...

Preprocess bean template, add template suggestions like view_mode

You can preprocess nodes and fields with hook_preprocess_field hook_preprocess_node, but when it comes to beans, you need to use different approach, hook_preprocess_bean doesn't exists. So to do this, you need to use this

function my_theme_process_entity(&$vars) {view_mode
if ($vars['entity_type'] == 'bean') {
if ($vars['bean']->type == 'YOUR_BEAN_TYPE') {
$vars['theme_hook_suggestions'][] = 'bean__' . $vars['bean']->type . '__' . $vars['#view_mode'];
}
}
}