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

Varnish makes forms like node add/edit "timeout" or not submit

I had a strange problem with Varnish, when users used form for longer period, like they inputed data and then submitted if it was 120 seconds or more, edit page would just refresh and nothing would be submitted. So I played with TTLs https://www.linode.com/docs/websites/varnish/getting-started-with-varnis..., then with pipe_timeout

Drupal commerce checkout redirect pause

When using different payment methods for checkout, sometimes you will have a payment gateway that will redirect you to different page, like paypal. But what if you want to have your frontender a chance to look at a page before redirect to style it?

You will need to stop the redirect, to do that just find that payment method info function in module, like the one below and change
'offsite_autoredirect' => TRUE, to 'offsite_autoredirect' => FALSE,

function commerce_payflow_commerce_payment_method_info() {
$payment_methods = array();

Git setup with hook for post-receive.

I have setup a simple git workflow.

In one directory on server I made bare repositroy

$ mkdir git-dir && cd git-dir
$ git init --bare

and in other one a folder for my live site

$ mkdir /var/www/www.example.com

then in the git-dir folder edit the post-receive hook

$ vi hooks/post-receive

and add this to file

#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f

after that, make this file excutable

$ chmod +x hooks/post-receive

Checking my.cnf settings that are not set

On my WAMP, or MAMP or normal server you may wonder what are the settings for your MySQL that are not set in my.cnf file. There are lot of them and to get quick look at defaults all you need is to run query (you can run it in phpmyadmin for example)

show variables;

and you will have all the variables and their values shown.

Create a view with specific number of columns per row without table

My frotend guy asked me to put 3 columns of data per one row in views output so he can put zen grids over them. Not sure if he really needs that but I made it for him with a view template. Selected unformmated display style type, created template
views-view-unformatted--taxonomy-term.tpl.php and added the code that detects when number 3 occurs, or to say what it in code, we check the ID and if it is divided by 3 and has no leftover (% module operator) then we detect it is time for a new group. Here it is:

<?php if (!empty($title)): ?>

Page to change only password and email

We needed to have a custom page or a block to only change email and password on that page, and the other user info we separated in different page. Sounds like a nice solution for users. So what we did is the following.

-custom menu item
-custom form
-validation and submit

Most of the code has been taken from user.module and adjusted to fit the need we have. So here is the code, ready to use.

/**
* Implements hook_menu().
*/
function password_email_form_menu() {
$items = array();

$items['change-credentials/%user'] = array(

Cancel button on drupal forms

This one is short but sweet. Usually drupal forms don't have cancel buttons that bring you back to previous page, so lets add one.

if ($form_id == 'user_profile_form'){
$form['actions']['cancel'] = array(
'#markup' => l(t('Cancel'), 'user'),
'#weight' => '666',
);
}

This will appear on user edit form and bring you back to user page when clicked.

Set the default address on shipping information with smart IP, refresh whole form to have proper counties(administrative area)

The title says it all :) add this to your module, into hook_form_alter and rock

//verify that this is not an ajax request, otherwise country changes will not be able to change the administrative_area information.
//in otherwise, let this section only happen once, and let ajax make changes as expected
if (!(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')) {
if ($form_id == 'commerce_checkout_form_checkout') {

Debug entitys etc

When debuging enteties normal dpm with devel module just wont do you any good. So use this

http://drupal.stackexchange.com/questions/33473/is-there-a-good-way-to-i...

and this for debugging or introspecting wrappers

https://www.drupal.org/node/1021556