Round Rock / Austin, Texas
Drupal Web Developer

PHP Tips

Check to see if Drupal Content Type in template.php

Today I came across some error messages on my Search Results page because I was checking for a content type in my template.php file's preprocess_page function. Here's some code to to check that you're actually on a node prior to checking the content type.

Drupal if Content Type
View Article

Trouble Getting your 'GET' Variables to Work?

Always make sure you do some error checking before trying to use the GET variable!

In this example we are passing something like this: http://www.foxwebdevelopment.com?year=2104

In our code we want to validate by using 'isset' before actually trying to use the value. Otherwise php is going to barf and throw and error such as "Notice: Undefined index: .... $GET"

if(isset($_GET['year'])){
     $year = $_GET['year'];
} else {
      $year = '2012';
}
PHP for GET Variables
View Article