Drupal Developers 101: How to organize your custom module

0 Comments

Drupal developers will always have their own style of coding, and module file structure conventions. On a project where there are two or more developers, it can be beneficial to have a unified way of structuring your custom modules.

One of the reasons why I prefer structuring custom modules is because it makes it easier to find functions or block of codes when debugging.

When all the team members’ are using the same file structure, it is easier for each of them to jump in and help each other debug things if needed.

If there are people on your team who don’t code the same way no worries. Simply having the same filename conventions, and placing functions in different files, in the same manner, makes your project more organized and easier to maintain in the long run.

Here's an example of a file structure that I have used on one of my projects:

module_name
-cck_content_types(exported content types, if necessary)
-js
-css
-images
-includes
-templates
--blocks
--views(overridden views template files)
--others

Site Documentation Module

0 Comments
Site Documentation Module

It happens quite often, that we have to work with Drupal sites, which were started by other companies or developers. In the beginning it's quite difficult to say what's going on with the site; how many modules are involved, how many custom content types etc. The more functionality on the site - the more complicated an upgrade/enhancement/re-branding can be. The more room for some potential issues/inconsistencies, the more pages to theme etc.

This is where the Site Documentation module can become very helpful.

The module exists not only for Drupal 6, but also for Drupal 5. Basically, the module collects the information from various sources (mostly the database), and appears on one page. You can set which data to report. You can also collect the reports via cron and archive the output HTML files to disk for future review. Hint, this can save your day when you're trying to figure out what was changed and when. (aside of your subvertioned code).

Websites that are surprisingly Drupal based

5 Comments

Sites that are Drupal based that you might not know about.
1. Michael Jackson’s Web Site ( http://www.michaeljackson.com/us/home )
A legend has passed but “his music will live forever.” Something that will keep his memories alive is his Drupal based website.

2. Universal Music ( http://universalmusic.com )
A big name in music, the best way to put it out is by using Drupal, one of the leading Content Management System (CMS) available.

3. Vancouver Aquarium ( http://www.vanaqua.org )
Vancouver Aquarium is one of my favorite places to visit. One day when I was checking for tickets online, I was surprised to see that their website was done in Drupal.

4. FLEX ( http://flex.org )
FLEX, what else I can say, I don`t think you even need to test if this site is really in Drupal or not because of the layout. Very familiar don’t you think? *wink wink

10 Must Have Drupal Modules

13 Comments

Drupal is great with not only its flexibility, but also with how easily it can be customized to your needs by adding a free module from drupal.org. However, it could be overwhelming for beginners to find the modules that best fit their needs. Therefore, here is a little help:

The Appnovation Must Have Modules List!

1- Administration Menu

The Administration Menu module is a great time saver! It creates a theme independent CSS-based menu on the top of the page with quick access to the most important administrative tasks.

2- FCKeditor - WYSIWYG HTML editor

Chances are that your client won’t want to be adding html tags to its content. Most people would rather use any sort of visual text editor then adding tags manually. FCKeditor is a great solution for those cases! It replaces Drupal's text areas with a user friendly WYSIWYG HTML editor.

Over-riding Views 2 Output in Drupal

7 Comments

I have been using Views 2 module a lot lately and the more I use it, the more I appreciate its elegantly designed architecture. It is very powerful and flexible. Popular modules such as Organic Groups and Location make the Views 2 module even more powerful. Showing information to end-users becomes easier when you want to show certain group posts or perhaps display the list of members of a group given a certain location.

I believe that the biggest factor which contributed to the popularity of Views 2 is its flexibility. You can pretty much override everything, from overriding its query using hook_views_query_alter(...), to being able to override its output at a very granular level(field result level).

Let's say that you want to show a yearly sales report of your 5 departments highlighting the sales per month. You can assume that a “department” is implemented as a node. Your have created a “Page” display of your View. The style of your View is set to “Table”. You have selected “Node:Title” as your department's name.

Here I will show you step by step process on how to override the result of a Views query.

1. Click “Theme:Information” under you Views “Basic settings”.

Modifying Views

4 Comments

We use the Views UI a lot to create custom pages, blocks, etc. Sometimes it does not give us exactly what we want and we would like to modify the generated sql query. It's possible to achieve this through the 'views_query_alter' hook. For example, we can do something like:

Drupal 5.0 View Module Bug

0 Comments

For an E-Commerce site that my company is working on, we need to create a View which shows a list of products based on 2 arguments. For those who do not know what Views Arguments is, you can check out this page.

Views arguments basically allows you to control the view using the URL arguments such as abc.com/argument1/argument2 . For example, you can control the view such that only content associated with the taxonomy term a and the taxonomy term b are displayed based on the url: abc.com/a/b . It is a really neat tool for controlling the information that is displayed as part of the view.

The problem with views is in having 2 taxonomy arguments as part of the code. For our case, we have a url: http://abc.com/a where a is the first taxonomy term and the other taxonomy term is b which is consistent across all instances of this view. There is bug in views such that when there are 2 taxonomy arguments, nothing will show up even though there is content with the 2 taxonomy terms.

The fix for this bug can be found here: http://drupal.org/node/77543 .