You are hereModules

Modules


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

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);

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

Creating custom forms for modal forms

If you want to create custom forms (custom window sizes) for modal forms, there is a hook in module that will let you define them. By default you have small, medium, large. This way you can create your own.

Use modal_forms_js_settings hook alter and just add data to $js_settings array

function mymodul_modal_forms_js_settings_alter(&$js_settings){

$js_settings['modal-popup-login'] = array(
'modalSize' => array(
'type' => variable_get('modal_forms_popup_extra_type', 'fixed'),

Change links section on User Login page

There is a good guide how to make custom login here https://www.drupal.org/node/350634

But to make some advanced changes I created this overrides. I repositioned the links below the submit button with deleting the array values and then adding it to the end of form array. Also I changed the text of the links to register and reset password

function mytheme_preprocess_user_login(&$vars) {

$items = array();

Getting user location on mobile phone or desktop and passing it to views filter

So this is not the cleanest thing possible and maybe some views filter should be made but I created it mostly for the purpose of adding extra button to search a search api index data with user current location. What maybe somebody doesn't know is that you can get user location with html5, so you will only need some little code and I also used reversed geocoding to get address from google api because I already have a filter that uses geocoded data.