Techniques for building Drupal Modules Quickly?
Asked Answered
X

5

5

I'm looking to see if anyone has any resources or tips for developing basic Drupal modules faster? Have you come up with anything to make your Module development faster?

The Drupal module documentation is kinda hard to understand and pretty massive. I'm wondering if anyone has simplified it and given techniques/tips for getting specific things done quickly. I'm currently looking for Drupal 6 and 7. Any help saving time will be greatly appreciated :-)

Xanthe answered 17/2, 2011 at 15:45 Comment(0)
M
7

In general, I'd recommend picking up a copy of the Productive Programmer. There's nothing earth shattering in it, but there are lots of small tips that can increase your productivity incrementally.

For Drupal specifically, Pro Drupal Development and Pro Drupal 7 Development, though not focused strictly on speed of development, are indispensable.

Beyond that...

Miquelon answered 17/2, 2011 at 17:0 Comment(2)
lots of good info here. I'm not looking at general coding techniques as I have my own ways of using IDEs/Version Ctrl/etc but the drupal specific stuff is what I'm looking forXanthe
Thanks for this, Matt V, though the stuff is pretty basic I learned from it ... didn't know about Form Builder or the Data module (I'd used table wizard before, but never Data). One really has to keep abreast of Drupal news, there are important developments every few months.Henleigh
T
3

Well, there really no fast track to it. If you understand the Drupal API regarding module development (install, menus, blocks, forms, etc) you will grasp it. The hardest part I remember was wrapping my head around the menu system.

One thing that helped was taking simple modules and seeing how they worked, and problem solving my own solutions. Reading Pro Drupal Development helps too.

Treachery answered 17/2, 2011 at 16:24 Comment(1)
thanks for the suggestions @kevin. this the book you're talking about? drupalbook.comXanthe
R
1

You basically need to have an understanding where to look (API function, hook, system... ) when you want to do X. There is really no need to memorize all hooks/functions in detail with all the arguments and stuff. That's something you can easily look up. Especially if you're using an IDE with I suggest (Using Netbeans myself).

Especially when you're altering stuff, try to develop some techniques to quickly figure out what code is responsible for the stuff you want to change. One example is to look at the hook_menu() definition of the module that does it and then check out the page callback and skim through the code. Things to look up: Are there hooks you can use, is it a form (if yes, what is the form_id, how is the form structured) and so on.

The best and maybe only way to get there (knowing where too look) is exercise. Every time you do something, you'll be faster the next time when you have to do something similar. I think what also helps is working on core/contrib modules together with others. You not only get to learn these modules better, you also learn how to read and understand code written by others better and you improve your own coding style.

Try to utilize proven, generic "building block" modules like Views, Flags, Panels, CCK/Field and so on. Then, the heavy lifting is done by these modules and you only need to provide the glue code to properly integrate them with your site. Might take a bit more time the first time you use these modules but you will likely save a lot time after that.

That having said, I'm not sure if the goal should be to build modules fast. I'd say the goal is to build modules better. Try to make them generic, secure, flexible, theme-able and so on with the goal to re-use these modules on the next site your building, when you need something similar.

Residential answered 17/2, 2011 at 17:14 Comment(0)
T
1

The majority of basic drupal module development is copy and paste. If you use textmate, the Drupal bundle for it allows you to build up key bits of modules (menus, theming functions etc) just by point and click (as it contains most of the necessary code snippets; you just fill in your info).

Following the module building tutorials is good too; the truth is, if you spent 3 or 4 weeks doing it day in day out, and you already have some background in coding, you'll be just fine.

Todd answered 17/2, 2011 at 20:36 Comment(1)
yeah I'm trying to find some shortcuts because my drupal development is such a small amount of work compared to my other projects. trying to bust out some functionality quickly. I do have TextMate (normally use Eclipse though). I'll check that out.Xanthe
S
1

Gedit for Drupal will preconfigure the very good Gedit editor/IDE for you.

For example, a new module: create an empty module file mymodule.example. Enter that file.

module<tab> And it expands into a full, predefined module.

Or in any module: hook<tab> to see a list of available hooks. Choose e.g. menu<tab> and it expands to a full predefined hook_menu. With <tab> you can walk trough all the variable parts in that new hook, to fill in the details.

Drupal.rb Has a.o. a $ drupal generate module "modulename" command that opens an interactive shell, wich allows building scaffolds for modules. The templates from which these scaffolds are built, are overridable.

Snatchy answered 23/2, 2011 at 10:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.