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

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

Drush

If you are running into this error while using drush

Directory ..../drush/cache/default exists, but is not writable. [error] Please check directory permissions.

Run this to solve it

sudo drush version
sudo chown -R $USER ~/.drush

MAMP - Drush, can't connect to Database

Using drush on local machine is great. If you have problems where drush can't connect to DB of your drupal, It is probably because of the problem with PHP path so either try something like this

https://github.com/drush-ops/drush#additional-configurations-for-mamp

which advise you to put your PHP path into PATH
export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.3.28/bin:$PATH"

and/or use this export DRUSH_PHP=/Applications/MAMP/bin/php/php5.3.14/bin/php to add variable to make your drush run.
Seems the first one is the one that does the trick here.

Some clever functions to check current users, subscribe to organic group etc

I have been building a custom module that has Inviting users to a group feature in it. So there are this helper functions that are very useful.

user_load_by_mail($invitee_email)

will check if there is a user with specific mail, returning false if it is not, returning user object if there is one user with that email

global $user;
$account = clone($user);
og_is_member('node', $current_group->nid, 'user', $account)

will check if there is a user(user object) in a organic group, probably currently logged in user.

Inviting Friends/Sending messages over Facebook, Drupal module/snippet

There is a cool Facebook feature that you can easily implement, inviting or sending messages to Facebook friends with Facebook SDK

Just build a module, a block or whatever you want and put this code in

What is important is to have a FB app and FB APP ID that you have set in some variable, I am using it here with
variable_get('fb_app_id', NULL)
We are using here SEND https://developers.facebook.com/docs/sharing/reference/send-dialog but you can also use other types like invite, request etc https://developers.facebook.com/docs/games/requests/v2.1

Drupal 301 redirect to another domain

This is not so much drupal but sometimes you will move your drupal site to other domain, so then to have your home and all other pages properly redirected add this code to your .htaccess file

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.some-domain.co/$1 [R=301,L]

Advanced modal forms - modal windows with CTools (singe and multistep)

So I client of mine wanted to use popups :) but not just ordinary popups, he wanted to put there, login, registration, node adding, notificiations, user invites for OG, simple menus and even FB login and registration. We also needed to save some user choices before the login/registration and act upon them after the user logs in. So spoiler alert now "if you want to save budget and time" dont't use modal windows or any popups for complex workflows.

Fixing some fatal errors

Recently I got to fix some older Drupal 6 site. It had WSOD so I needed to add this to index http://drupaldump.com/wsod-or-white-screen-death-and-error-reporting and then I saw sort of this error "Fatal error: Unsupported operand types in common.inc" so I used this post https://www.drupal.org/node/362799 and added this code to the "l" function, and solved this bugger.

if (!is_array($options)) {
echo " "; $backtrace = debug_backtrace(); var_export($backtrace[0]); die(); }