My first contribution to Drupal.org
Printer-friendly versionSend to friendPDF version
I made my first contribution to Drupal.org.
It concerns redirections of login. Login destination is a useful module for redirecting users after they logged in. You can redirect depending on roles, but I needed rules depending on which node the visitor was entering from.
http://drupal.org/node/418488#comment-5185866
My client wanted users to be redirected to various places depending on the current node of the anonymous visitor.
The homepage was node/739 and if the visitor was there when logging in he/she would be redirected to the intranet's homepage: /my. Otherwise it should not redirect. The problem is that two pages were rendered by views, so I had to add more conditions.
Here is my code:
$node = menu_get_object();
// The statement below concerns a view of a map, ie it does not have a node id.
if (arg(0) == 'about' && arg(1) == 'branches' && arg(2) == NULL) {
return arg(0) . "/" . arg(1);
}
// The statement below concerns a view of a city (arg(2) is the country in the path and arg(3) is the city) in a map, ie it does not have a node id.
elseif (arg(0) == 'about' && arg(1) == 'branches') {
return arg(0) . "/" . arg(1) . "/" . arg(2) . "/" . arg(3);
}
// The statement below concerns another view which path is /success-stories. It does not have a node id.
elseif (arg(0) == 'success-stories') {
return arg(0) . "/" . arg(1);
}
// The statement below redirects to the intranet homepage (/my) if the login takes place at the homepage (which in this case is node/739)
elseif ($node->nid == 739) {
return 'my';
}
// The last statement: if none of the first three conditions are valid then do not redirect!
else {
return 'node' . "/" . $node->nid;
}
Hope you find this useful.
Peter Lindmark
Are the key legislative pillars such as Basel II & III, UCITS IV and Solvency II forcing you to re-examine how you identify, measure and manage risk and capital?
Is the goal of your website to sell services or products, educate, or collect data?