Home | Topics | social media

My first contribution to Drupal.org

Printer-friendly versionPDF 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

 

Short URL
Asymptotix on Twitter

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?

Asymptotix work closely with our partners to help clients develop a more proactive, systematic and integrated approach to governance and risk management to deliver proper value.

Asymptotix can offer the support you need to deliver on time. Read more...
 

Is the goal of your website to sell services or products, educate, or collect data?

A positive customer experience is vital to conversion, no matter what your conversion goals may be. Our designers and developers will create a positive experience to maximize your conversions and deliver the optimal return on your investment. We strive to find the perfect balance between the web site’s design and functionality.

Asymptotix implements interactive solutions for European companies. From corporate websites to social communities, our clients will tell you an investment in building a scalable online experience will deliver long-term tangible benefits.

Based in Luxembourg we can help you all over Europe. Our multi-lingual team can work with projects and speak your language! Read more...