You are here

Programming

Using Formulas with Views & Hook Views Query Alter

Requirement: Get a list of store locations within a mileage range.

Setup: A Location content type with fields for the address, zipcode, city and state. Client wanted them separately so using the Location or Geolocation would not have done much for us. Though I only spent less than 30 minutes with each of these to see what they had to offer for what was needed.

Challenge: Perform a mathematical formula in Views using the hook_views_query_alter.

Beans - Create, Preprocess, and Theme.

This is a simple example of code (template) snippets to work with Beans, including the creation, preprocessors, and theming.

For this example I will be creating the Bean through the GUI and locking it in a Feature. This is good for high-paced development, and at least for what I have used Beans for, I haven't had the need to create one programmatically, yet.

Beans turns blocks into an entity, Block Types; which then you can create instances of each block type, have fields, view modes, etc. Just like you would with a content type.

Drupal Best Practices & Standards

Here is a collection of links to great blogs written by some of our best Drupal comrades. I have stumble upon these blogs again and again and have found them very helpful while developing. I highly recommend reading through all these.

48 Essential Drupal Development Tips From Lullabot

This is an awesome collection of Drupal development best practices by Justin Emond at MissingFeatures.com

Eclipse Plugins I Can't Live Without

Since I have been working mostly on back-end development, specially under the Content Management System (CMS) Drupal. I prefer to use Galileo's flavor of Eclipse. The reason why I have always use Eclipse is simply because I was introduced to it while developing Java applications as well as Android Apps.

Interview Questions

These are some of the most common questions I have been asked and ask myself on interviews for LAMP positions. I will update these questions and possibly answer some of them on my spare time.

Something important: If you mention knowing something on your resume, expect to be asked about it.

Drupal

Note taking questions.

Drupal Hooks and Functions I Can't Live Without

Archive of Drupal's Hooks and API functions I constantly use. This blog will be updated regularly since it is used widely for reference.

Cross Domain Access to JSON Data Returned by Drupal's Hook Menu

In this article I will talk about how I access JSON data processed by a Drupal Hook Menu's page callback from a remote domain. The idea here is that sometimes we want to take advantage of Drupal powerful Hook Menu (hook_menu) system to register paths and handle the processing of data for that page request.

HOOK MENU

hook_menu

First, I'll add a menu item so that we can register the path that when access will return an object in JSON format. for this example, I will use the name mymodule to refer to the module where all the code will be saved.

Handle PHP & JavaScript Global Variables in Drupal

Declaring and accessing PHP and JavaScript globals is not as straight forward as I thought it would be. first of all I'm going to go over how I first tried to implement PHP and JavaScript global variables and then what actually worked for me in Drupal 5 and 6.

Handle PHP & JavaScript Global Variables in Drupal

The PHP documentation on global variables - can be found inside the Variable Scope section - implies that if a variable is used within the context of a global variable, then the scope of this variable will span to includes and required files.

cURL vs. getimagesize vs. file_get_contents

getimagesize()

The geimagesize() function allows us to determine the dimensions of an image, as well as the file type e.g. JPG, GIF, PNG. and the HTTP Content Type. Though this function is listed under the GD and Image Functions, this function does not require the GD image library.

Usage

This function will return an array containing the image information including the HTTP Content Type or MIME type which helps deliver images with a valid content-type header, or FALSE if the image information was not retrieved.

Setting Apache Virtual Hosts on Windows & Mac

Virtual Host

Setting up virtual hosts gives us the flexibility of setting up multiple hosts on a local machine, in other words we can use this method to host more than one domain name on the same machine, including of course on servers running locally. Usually when you setup Apache, you dump all your sites under htdocs and then you access them on your browser by using localhost/[directory-name]. Although this is good, sometimes its not convenient. For instance, when using CMS applications such Drupal or WordPress Mu, you might want to be able to setup multiple sites under the same local installation so that it mimics your live site installation.

To setup multiple hosts, we're gonna edit two files under both Windows and Mac. One of this files will be used to create the hosts, and the other will be used to map the hosts to our local IP address. Also, in order to modify these files you must use an account with administrator permissions.

Pages