Dev Mashup: Building a dual MySQL 4.1 and MySQL 5 dev environment in OS X 10.5 Leopard (and more)

I've been wanting to upgrade to MySQL 5 for a while now, and after hearing that MySQL 5 is required for Drupal 7 I decided to bump up my upgrade schedule, pronto. If all one wants is MySQL 5 then that is easy enough -- go download MAMP and you're done. But what if you want to be able to dev on MySQL 4 for projects that require it for whatever reason (e.g., clients who are run it and are not willing/able to upgrade MySQL at the moment)?

Well, with not a lot of effort - it very easy to have a PHP 5, PHP 4, MySQL 5, and MySQL 4.1 environment - all sharing the same doc root and servernames (e.g., urls):

Step one:
Configure Apple's native Apache, PHP, and add a free-standing MySQL 4.1 install (since MAMP comes with MySQL 5, right). Here are two good links to get you on your way to doing this:
Install Drupal on Mac OS X 10.5 Leopard
Working with PHP 5 in Mac OS X 10.5 (Leopard)

...if you are migrating a free-standing MySQL install from a previous install you may want to check these articles out (1, 2) as well.

Note: Getting all of this totally set up and working right, including setting up your virtualhosts and /etc/hosts file, before installing MAMP will pay off.

Step two:
Download MAMP and follow the readme.txt instructions and/or use these links to setup the basics:
HowTo: Create a local environment using MAMP
Install a Local Web Server on Mac OSX

Step three:
Now it's time to integrated these two completely separate environments so that you can keep a common doc root, virtualhosts, and urls, and systems tools (we'll get terminal access going for MAMP's MySQL):

We'll make it so that we can keep all of our sites, no matter which enviroment they require, in a common place -- and so that no matter what we're running we will always be able type in "localhost", or and know that it will take us to our doc root (instead of having to remember to type "localhost:8888/" for MAMP:). Relatedly, doing the steps below lets us keep common server names (e.g., 'mysite.local') across environments.

So now:

* Change the docroot in MAMP's httpd.conf (line 368) to:
DocumentRoot "/Library/WebServer/Documents"

15 February, 2008

jQuery UI 1.5 and jQuery Enchant 1.0 alpha work with Drupal 6!

The jQuery team has just released an alpha of jQuery UI 1.5 and jQuery Enchant 1.0, both of which will work with Drupal 6, as it is stated that the minimum requirements for the alphas are identical to the version of jQuery that ships with Drupal 6!

Some links to help you get your tinker on:



[Note: even if the jQuery version requirements for UI and Enchant change at some point before the final release, rest assured that someone in the Drupal community is sure to make an upgrade path available] ;-)

10 February, 2008

Hyper-dynamic Drupal sites with Panels and Views

The motivation for writing this article came from my feeble attempts at trying to discuss a module I'm actively working on (to be covered in a future article) with several very intelligent Drupal developers. Due to the inherently abstract nature of the issues, and for lack of a common language, the end result was that in every case each person just ended up scratching their heads at me without really comprehending what I was really trying to get at.

Hyper-dynamic defined
Technically speaking, Drupal offers a dynamic framework right out of the box, right, so what is meant by "hyper-dynamic"?

Hyper-dynamic, for lack of a better description, refers to sites/sections-of-a-site for which pages do not exist as individual nodes, AND which (for example) are more complex than a single static view/panel. A panel/view which takes arguments, particularly multiple arguments, is an example of hyper-dynamic content delivery.

Getting down to business...
How is this idea of hyper-dynamic content useful and/or or what are the use cases?

As a 'simple' example, let's say we have a multi-regional travel site which caters to people looking for info/deals on casinos. For each region, we'd like to have a separate homepage, AND separate landing pages for each casino within the region. Finally, let's throw in a "Deals" subpage for every region/casino.

So the site hierarchy would look like this:

Name that tune
The challenge is to figure out the fewest parts we can make this architecture, while still maintaining flexibility/maintainability/upgradability.

In this case, we can accomplish our proposed site hierarchy, for an unlimited number of regions/casinos, with as little as 3 views, 3 panels, 2 content-types, and a handful or arguments:

Views used
1. "Node listing" - provides node-listing for each region/casino determined by arguments. This view is placed in the "Landing panel" (see below).
2. "Deals listing" - provides deals node-listing for each region/casino. This view is placed within the "Deals panel" (see below).
3. "Homepage listing" - provides node-listing for homepage. This view is place within the "Homepage panel" (see below).

Panels used
1. Landing panel - Provides complete landing page for each region/casino based on arguments
2. Deals panel - Provides complete "Deals" subpage for each region/casino based on arguments
3. Homepage panel - Provides homepage. Could theoretically even get away with just using the landing panel for this, but by using a separate one for the homepage we get a little more
flexibility and sanity.

13 December, 2007

Drupal upgrades/updates and how to approach them

Published in: 

There is perhaps no other Drupal-related issue which commands so much attention from site admins, Drupal developers, and Drupal core alike, as the subject of Drupal updates/upgrades.

The Players

Site admins typically want to have the 'latest and greatest' version just for general purposes. This is, of course, very understandable, all other things being equal.

Drupal developers like to be able to keep up with the latest release for various reasons: a) to take advantage of new features, b) to keep their skills current, b) because their clients want it, c) as any bonafide geek knows, it's alway fun to check out the new toys.

Drupal core is always concerned about Drupal updates, well because...it's Drupal core. The project and Drupal itself is dead, or at least frozen in time, if it ceases to innovate at semi-consistent intervals.


In a perfect world everyone - site admins, Drupal devs, and Drupal core are always perfectly in sync - all the time, 24/7.


Keeping up with the current version of Drupal core is not always practical. In some cases it might even be downright detrimental! This statement applies particularly to start-up sites, and/or people who are short on time. But you know what...

...IT'S OK!

Having the latest version of Drupal, in and of itself, will likely have little to do with the success of your site. Though each iteration of Drupal does represent it's own quantum leap forward, that is not to say that versions before it are garbage. While this point may seem obvious to many, I've spoken with numerous people who seem to regard anything but the latest version of Drupal as a 'dinosaur'. That's just silly.

By all means - if time is pressing in on you, or your budget is strained, keep up with the latest security updates for your particular version of Drupal and don't give it another thought until there is a more opportune time to upgrade.

By the way, if the new version of Drupal less than 2-3 months old, this advice especially applies for sites which use numerous contributed modules. While many modules are updated before or soon after a new Drupal release, experience has shown that many others contrib modules do not get upgrades and/or reach stability for at least 2-3 months after the initial release date of Drupal core.

Bottom line

Don't be in hurry for your Drupal upgrade if the timing isn't right. Sometimes good things come to those who wait.

28 October, 2007

Announcing the Advanced Theme Construction Kit (atck)

I am pleased to announce the official release of the Advanced Theme Construction Kit (atck) (project page):

atck was developed in a production environment for purposes of quickly building css and xhtml valid Drupal themes from scratch without having to un-theme an existing Drupal theme to do it.

atck components include:

1. WYSIWYG grid builder
A browser-based grid builder which produces starter code for a page.tpl.php file. The grid builder itself was originially built by Christos Constandinou and it uses a modified version of Yahoo Grids which is more flexible and easier to customize. With Christos' permission it, and the supporting css, has been customized so that it works for Drupal themes and so that it is css3 valid. Access the builder online (FF only!), or download it and run it locally. [builder cannot be on Drupal.org because of MIT license]

2. style.css [separate download because of BSD license]
style.css contains only the css needed to support what the grid-builder outputs, as well as some general 'resets'. The only modifications one should need to make here would be if they want to make their layout a fixed width and/or a different width (default widths are in %).

3. page-layout.css and template.php
These files are where the visual styling of the site happens. The source of these files is from a combination of code from the Hunchbaque theme and some changes/additions which I added in order to provide baseline settings I prefer and/or provide more granular settings. The beauty of these files is the simplicty of them - they include as little markup/styling as possible to avoid complexity, while at the same time putting many helpful tools/comments at your finger tips so that you can accomplish what you want.

4. page.tpl.php
A sample page.tpl.file is included as a reference for finishing your own page.tpl.php file using code output from the grid builder. Note particularly the variable names for the blocks, regions, menus, etc. (at this point the builder does not include those items)

5. fix-ie-6.css and fix-ie-7.css
These files are included for purposes of providing IE-only css to each of the respective versions. By using conditional comments like this we keep the main css files hack-free and atck css3 valid.

Please keep in mind that this is an initial release - comments, contributions, etc welcome! (please file such things at the project issues queue though)

21 October, 2007

Advanced server/spam bot blocking

Published in: 

As promised in an earlier article about blocking server spam, here are some advanced tips on shutting the door to these resource leeches:

#1: Non-existent urls getting hammered:
This is can be a major problem, one which I believe has been at least somewhat cured in Drupal 6, but for Drupal 5 and below a request to a non-existent page such as http://yoururl.com/node/vote/ does not trigger a 404 page as you might expect. Instead the entire front page loads up. Annoying enough as it is, but when combined with a confused/malicious bot that continually hammers the non-existent url, the resource load can be enough to weigh heavily even on dedicated server, let alone a shared-hosting account. [note: there is an update in the comments below with more specific information about the versions of Drupal which are affected by this problem]

What to do about it:
Certainly putting any paths you see that are getting hit this way in your robots.txt file is a good idea, but that does not always solve the problem. Sometimes more drastic measures are needed. Below is snippet from an actual .htaccess file that has on several cured malbot instances that were causing significant server slowdowns - feel free to use and append yours appropriately (be sure you do not have a line break before the [OR] if you copy this - and also be sure your last line does not have an [OR]):

### Forbid access to bot-beaten non-pages
RewriteCond %{REQUEST_URI} ^/node/forward($|/.*$) [OR]
RewriteCond %{REQUEST_URI} ^/blog/comment($|/.*$) [OR]
RewriteCond %{REQUEST_URI} ^/blog/node/forward($|/.*$) [OR]
RewriteCond %{REQUEST_URI} ^/blog/blog($|/.*$) [OR]
RewriteCond %{REQUEST_URI} ^/storylink/forward($|/.*$) [OR]
RewriteCond %{REQUEST_URI} ^/node/blog($|/.*$) [OR]
RewriteCond %{REQUEST_URI} ^/_vti_bin/404.html($|/.*$) [OR]
RewriteCond %{REQUEST_URI} ^/categories/node($|/.*$) [OR]
RewriteCond %{REQUEST_URI} ^/node/accessories($|/.*$)
RewriteRule .* - [F,L]

#2: Have an IP? Awesome. Now keep bots from even reaching apache
If there is anything good that can be said about server malbots, as compared to their comment spamming cousins, it's that typically a server-spamming bot will have a static ip address instead of a (dreaded) dynamic one. This makes banning it much easier, of course.

16 October, 2007


Subscribe to RSS - Drupal