Tutorial

Understanding the theme() function on Drupal

May 25, 2009

One of the most complicated things to understand when templating or developing modules for drupal is the theme() function. But when you know how to deal with it is really useful even when there's no way to know how many we have available. The way to use it fairly simple, let's see how the Garland theme builds the primary links:

print theme('links', $primary_links,
array('class' => 'links primary-links'));

The first argument is the actual hook we are calling, the second and third are the the arguments we are passing to that functions. So basically the theme function will output plain HTML and it's actually way cleaner than defining a function or coding a lot of php on our template.

Drupal and GIT

May 10, 2009

During this year I've been moving my projects to GIT. While my private projects are on this server, my public ones are on GitHub as Open Source. Git is a really wonderful version control tool for any kind of project. It makes it easy for me to deploy, maintain and update my current sites. I just wish there could be a way to include the database on it. In this post I will explain how I'm using GIT to manage a Drupal site on both local and live environment. And since most people already have a site working, I will explain starting from an existing site.

Create the repository

The very first thing is going to the actual site, in my server this site is in: /var/www/sitename.com/public

cd /var/www/sitename.com/public
git init
echo "sites/default/settings.php" >> .gitignore

You can also run this if you want to ignore the files folder (that's really up to you)

echo "sites/default/files" >> .gitignore

Then you have to add all files to the repository and make the first commit

git add .
git commit -m "Initial commit for this site"

.htaccess hotlink protection

Jan 16, 2009
Protecting your site from hotlinks can be really useful to prevent other sites stealing bandwidth, but it's also comes handy when you want to protect files from private areas. The first 2 lines are responsible from redirecting all the traffic from www.yoursite.com to yoursite.com and the third and fourth line is for preventing hotlinks, in this case PDFs and SVGs.

Pwnage Tool 2.1 Tutorial for Mac

Sep 16, 2008
Ok, after I made the big mistake to update my 1st gen iPhone to the 2.0 OS, I've been having TONS of problems with the device: Safari crashes, call crashes, Map crashes, etc.

Building a web application layout 2

Aug 09, 2008

Maybe you will be interested in reading Building a web application layout 1 if you need to know how did I setup the xhtml and basic CSS. In this part we will try to acomplish two things: Insert a javascript dropdown menu and apply the design I did just to this application.

Building a web application layout 1

Jul 18, 2008
In a way to build an entire layout for a web application we need to know what exactly we need. In this case I'm going to use a 90% width with a top menu, left menu and a right handed help box used to explain what the current section does. It's always useful to draw a mockup of the layout we want to achieve. Since this is a kind of simple layout we don't really need it, but I still did it.

Drop Down Javascript Menu

Jul 05, 2008
When developing web aplications I usually need to put all the menu in a tree-like organization.