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

Views and custom dynamic titles for pages set with fields values or anything else

By default you can't set dynamic titles for views other than using contextual filters and using them to change title, this will sometimes help and sometimes you want to use something else, so custom modules/overrides to the rescue. There is also a page title module but you can use tokens with it and seems it doesnt work now. So use one of this 2 hooks and you will have plenty of info to choose from to set your title. You can use field values, or any other part of view and just put it into title. Here are 2 examples I used and both of them work fine.

Insert something every nth row in Views

Most likely you will want to insert an ADD, probably adsense add every nth row in views. To do that there are 3 methods. One of them is a module a guy made that acts as global filed you add and then you enter what goes in there, problem is that JS code doesnt work there as it is html only field, so some custom formatters should be added. 2 other methods are more straightforward, you just edit the template file and add code there every nth row or you make a view override and on creation of view add a line of code, it can be a node or something else. Here is the list of them with links

Remove/hide Vertical tabs on node edit forms

Node edit forms are not the nicest thing you have seen and new layouts in Drupal 8 that basically copies wordpress style forms are much better. Sometimes you will have clients that can't stand this vertical tabs and would rather not have them at all and probably they will never use them anyway. So best thing to do is to remove them for them. Just add this to your module, which will hide them for them and for user 1 you will still see them.

function custom_form_node_form_alter(&$form, &$form_state) {
global $user;

if ($user->uid != 1){

Rules, action for first time logged in user

If you want to have an action happen on user who logs in first time and logs in right after the registration, without email verification. You can use the event "After saving a new user account" problem here is the in conditions you will not have any data about the current logged in user, as he will be logged in after that. So even if you check global $user it looks like the anonymouse user.

Modal CTools redirecting after modal is opened

Usual redirecting wont work if modal is opened. So to do that you need some custom code like this will work for redirecting after loging in.

function custom_user_login(&$edit, $account) {
ctools_add_js('ajax-responder');
$commands = array();
$commands[] = ctools_ajax_command_redirect('first-time-login');
print ajax_render($commands);
exit;
}

There is also a Rules redirect action if you install Modal Forms module, that has redirect modal aware, you can check the code there or just use it if you use rules.

Plain modal form, load on page load

To load just plain moda form and add some contetn to it. Do this

$(document).ready(function() {
Drupal.CTools.Modal.show();
$('#modal-title').html('put title here');
$('#modal-content').html('put content here');
});

and modal will open.

Loading CTools modal on page load for specific pages

This is my first solution in series of solutions for automatic loading of modal forms. If you have a link on some page that you want to load on page load. You need to first create JS that would make that and then find a way to add that JS to specific pages. So first JS

(function($){
Drupal.ajax.prototype.specifiedResponse = function() {
var ajax = this;

if (ajax.ajaxing) {
return false;
}
try {
$.ajax(ajax.options);
}
catch (err) {
alert('An error occurred while attempting to process ' + ajax.options.url);

Overriding form, setting something for the first form load

So I am overriding the login form and want to have unique state of the form for the first load screen, when user hasn't entered anything yet. What do I do, I tried to get what is the difference with form vars when submitted and when never submitted. I found out you can do this by form ID as it changes each time (which is not so good for theming of the forms). Somehow more convenient was to look at $vars['form']['#validated']) that is not present on the first load, so if it is not there I just do some custom actions

function my_theme_preprocess_user_login(&$vars) {

Theming whole modal form with custom class

In the previous post I wrote about the way to create custom modal form sizes. This time I will add a class to each window, so you can also theme them totally. Currently by default there are only generic classes and you can make one header of modal form different then the other. You can only theme form part as form element has unique class. As in former post I created