Drupal blog

Modifying a view with hook_views_query_alter

If you ever find yourself in a situation where you need to manually change the some parameters in a view then hook_views_query_alter() is your answer.

I had a situation where I had a view of CTA links. These links consisted of a title/image and link to the content. These displayed a the bottom of the article content types. Each CTA had a path to a specific article. The problem was that I didn't want the same link to display on the article that was current. So to do this I used hook_views_query_alter().

 

Sending a webform to a different email based on country

I can confirm that this work around does seem to work. Whether it's a good way to do it or not is another matter. This webform hook is called after being submitted to the db but I don't think it matters where it's done. It basically uses the country codes generated by the country select box to define the email used

<code>
<?php
function MODULE_NAME_webform_submission_insert($node, $submission) {

if ($node->nid == WEBFORM_NODE) {

Unable to login to admin

I had a problem, I developed a site on apache on a windows machine, but I also wanted to develop the site on my Linux (Ubuntu) laptop. After transferring the site across, files and database I just couldn't login. Whatever I did it just went back to the login screen without logging in.

I tried every solution out there, changing the password hash code through the database, changing the password through drush. Absolutely nothing worked. Finally I found the answer and I hope it works for others. But don't be surprised if it doesn't.

Custom HTML in Drupal 7 menus

One of the things I find with Drupal is although the documentation is very good it's often quite hard to get the information you need, especially when it comes to just straight forward walk throughs of how to do things. I had a problem where I needed to add a vertical line between my inline menu items. Check out the portfolio page to see what I mean. I wanted it on that menu alone and no other. Well obviously what I had to do was change the HTML output by adding in a line like

Subscribe to Drupal blog