Want to get Lullabot article, videocast, and podcast announcements delivered right to your in-box?
Let us know your email address (we won't share it) and we'll let you know when anything exciting happens.
Drupal Podcast No. 50: 50 Drupal Tips and Tricks
- Artist: Lullabot
- Title: Drupal Podcast No. 50: 50 Drupal Tips and Tricks
- Album: Drupal Podcast
- Year: 2007
- Length: 79:11 minutes (18.8 MB)
- Format: Mono 22kHz 33Kbps (VBR)
Here's the list:
Drupal admin and configuration:
- Create a "HTML help" block and assign it to appear on only "node/*/edit" and "node/add/*"
- Use the "edit permissions" link on admin/user/roles to get a single column
- Use the Firefox Web Developer Toolbar to "Populate Form Fields" on the access page for the admin role
-
Use "
site:drupal.org {search terms}" to search all of drupal.org with
Google. Set up a Firefox shortcut so you can type "dru [your search]" to
search Drupal. Alsoapi.drupal.org/apis/{search_term} - When using pathauto to alias usernames, don't let users change their usernames.
- Use PathAuto and Path Redirect together to redirect old aliases to the new ones. Search engines will love you.
- Use Global Redirect to make sure home page is "/" and current page doesn't have an alias.
- When creating PathAuto template, keep uniqueness in mind -- perhaps add a date to your blog and news entries.
- Move the "My Account" menu item by creating a custom menu item at 'user'
- Use update_status module along with cvs_deploy & cvs tags to manage sites
-
Use ImageCache to resize images. It's worth the poor u.i. and configuration challenges. Tastes best with ImageField, CCK, and Views.
- Turn any CCK type with an imagefield into a photocast with ConTemplate
- Use Automatic Node Titles whenever you want to have separate (CCK) fields for first name and last name, but you want the node title to contain the full name.
- Use SimpleMenu to remove the need for an admin block on the page.
- Set your site in "offline mode" when doing Drupal upgrades, to ensure that your end users are never exposed to any funky errors.
- Use locale.module to change English text into other English text. Example: change "Forums" to "Message Boards". Slight performance issue for high-traffic sites. In Drupal 6, there's a new "locale lite" feature to translate only a few pieces of interface text without the overhead of locale module itself. Check the bottom of default.settings.php for more details.
- Use views + views_fastsearch to build "section search" or custom advanced search pages
Drupal.org
- Enable the contributor block on drupal.org. This will give you access to all kinds of useful links, as well as tell you how close we are to releasing Drupal 6.
- Check out the Drupal Planet at http://drupal.org/planet to keep up to date on exciting developments and what various folks are working on.
- Post suggestions or bugs you find with Drupal or contributed modules to the issue queues, not on the forums. They're much more likely to get attention from developers there.
- Check out http://drupal.org/node/10259 for some tips on posting to the issue queue, including how to make a good bug report/feature request, how patches get reviewed, and so on.
- Head to http://drupal.org/videocasts to view a categorized archive of various Drupal videos and presentations on a variety of subjects.
-
Sign up for the security announcements at http://drupal.org/security to keep on top of your updates!
-
Ninja search #1: Negative words. Eliminate the words you don't want with a minus in front: -Joomla
Ninja search #2: Content types: type:forum or type:image etc.
Ninja search #3: Phrase search. Put exact phrases in "", as in "Drupal rocks".
Theming
- Set up a quick "wireframe" site using Zen or another simple theme. Show this and the HTML it outputs to your web designer before they start working. Point out items like tabs and messages.
- Change your administration theme when working on a new theme
-
Get to know Firebug for ALL front-end development: JavaScript and CSS!
-
inside any template file to see what variables are available.
<?php
var_dump(get_defined_vars());
?> - Create a hook_link_alter() and add a "More..." link to the end of the Teaser text while removing the Read more link
-
The format_interval() function
is cool. It outputs "X minutes Y seconds ago", or similar... -
Accommodate page caching by substituting dynamic page elements in your theme.
If the user is not logged in, use absolute values such as "posted on {date}
at {time}", rather than relative such as "{X} hours, {Y} seconds ago".
Views
-
Use
theme('view', {arguments})to embed a view anywhere in your theme's template.php or .tpl.php files - Use the custom argument handling code in a View to change anything about a view: filters, number displayed, fields, and of course arguments. You can alter these items with or without conditionals. Change the number of columns in a grid view; change the number of items that appear if the "feed" argument is present; etc... (see #36 to see the view object)
-
Use "promote to front page" / "sticky" to do other things using Views... see also Views Bookmarks
-
Use Views + Taxonomy
Redirect to use a custom view for each vocabulary's listing pages. -
Use
print_r($view)inside the 'Argument code' field of a View to see the view object. see #33 (oops) - Give any number of 'block'-only views the same page URL, and their [more] links will all point to the same page.
JavaScript
-
Translate your javascript by doing
Get translated strings from javascript:<?php
drupal_add_js(array('my_module' => array('my_string' => t('My string'))), 'setting')
?>Drupal.settings.my_module.mystring -
Same with urls: It's more reliable and less work than using $base_path and Clean URL setting.
<?php
drupal_add_js(array('my_module' => array('my_url' => url('node/10'))), 'setting')
?>
Drupal Development and Coding
-
DON'T HACK DRUPAL
- Many IDEs (Zend, Komodo, Eclipse) will parse Drupal's code base and give you autocomplete and documentation on the function names
- Run a local copy of api.drupal.org (using api.module) -- parse contrib modules! Documentation here: http://drupal.org/node/26669
- Figure out arg(), you won't be sorry.
- Use $_GET['q'] anywhere in your site to get the real Drupal path (not what's in the menu bar)
-
Find out if the current user is logged in:
<?php
if ($GLOBALS['user']->uid) {/* the user is logged in */}
?> - In Drupal 6, the contrib Schema module will generate a full-documented list of Drupal's tables. See http://jaspan.com/drupal-6s-self-documenting-database-schema and http://drupal.org/node/184586.
- Use cvs annotate to track down the hows and whys of a particular line of code. View a how-to at http://www.lullabot.com/articles/cvs_annotate_or_what_the_heck_were_they_thinking
- Coder module can not only be used to check over code for coding standards compliance, but can also be used to notify you of things that need to be done to your module to upgrade it to the next Drupal version.
-
On api.drupal.org, you can use the "List references" tab on any function to view where else in the source it's called, as well as what other functions are called by the function you're looking at. This can be helpful if you have a question about how a function is used.
- Drush!
Comments on this post will automatically be closed three months from the original post date.



RSS Feed


Comments
Happy aniversary!
Happy anniversary!
Wow!, this is going to be the Great one, thanks.
Happy 50TH!!!
Once again, another great podcast!
firebug?
Safari has a cool 'Inspect Element' in 3.0!
Make sure the debug menu is visible and context click on any item....
Also, use drosera to do source level javascript debugging.....
pretty cool
http://www.macosxhints.com/article.php?story=20071028040012452
Great list!
Congrats and thanks for the awesome list!
There's also the IE Developer Toolbar to get Firebug-like features while doing theme testing in Internet Explorer: http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4...
Very good podcast and tips.
Very good podcast and tips. Congrats for your show number 50.
Pause button
I had to disable images for lullabot.com so I could click the pause button. :/
You can also download the
You can also download the complete podcast as an mp3 file and play it form your local hard disc hopefully without problems hitting the pause button.
Awesome tips!!
Once again, a great podcast. There are some really fantastic tips in this list - my favourite is the local api website setup. So often I am developing without an internet connection, so this will really help me out. Thanks! I'm bookmarking this page for future reference, as there are so many great tips here, its going to take me a while to investigate all of them.
One tip I can give you guys is an alternative to the SimpleMenu module, and that is admin_menu. It uses just CSS to provide a drop-down list of all admin menu items. Very cool.
Tasty tips
Thanks for these. The tip on moving around /user seems so obvious now that I've heard it. hook_link_alter is also immediately useful to me — I just implemented a change to comment_link this way. Woo!
For what it's worth, var_dump() gives you a bit more information about a variable, like how long strings are and that kind of stuff. print_r leaves that extra information out to make things a bit more readable. That's my understanding, anyway.
On the Firefox shortcut tip, for Mac users using Camino, these are called Bookmarks Shortcuts. I love these things to death. Here are two I use all the time:
d - http://api.drupal.org/api/search/5/%s (forces an API search on version 5)
dp - http://drupal.org/project/%s (go straight to a project page)
FireFox Search Plugin
I created a simple FireFox plugin to search drupal.org. This uses the same concepts found in tip# 4.
It can be found here: http://ucit01.uncc.edu/node/200
Re: Firebug
Hey, Great podcast. Re: Firebug in the new safari 3.0 included with leopard the web inspector tool is greatly improved.
defaults write com.apple.Safari IncludeDebugMenu 1Run the above command in terminal, to enable it. Restart safari and right click on any web page "Inspect Element" or go to the "Debug" menu and choose "Select Web Inspector". This can be docked to the bottom of the page like firebug (see little buttons at bottom of sidebar), it has almost all the same features. I'm not going back to firefox.
Hugs all round!
You all deserve one!
Great podcast, as ever.
tip 29
Thanks for this article!
Please explain tip 29 (may be short example)?
Thanks guys!
This was really useful.
Some of my hints.
Instead of using drupal_get_path_alias() to get the alias of the current page, you can use $_REQUEST['q']
If you want the real path of the current page then you can use $_GET['q'].
Also for views the search is included by default, so you don't need to install fastsearch. But fast search will give you more options.
Awesmore!!
Lullabot rocks!
Many thanks.
You really care for Drupal and its users.
"My Account" Menu Item
You guys were asking if with the menu system in Drupal 6, you can move "My account"... Well, you can! And by dragging and dropping! Yay!
Thank Lullabot! Use Drupal
Thank Lullabot!
Use Drupal has become even easier.
pretty print_r
In the podcast it says look at the source to see the formatted version of the output if you use print_r (amazingly useful function). If you put it inside a pre tag then the print_r function output will be formatted within the browser too.
eg:
<?phpprint('<pre>');
print_r($vars);
print('</pre>');
?>
Devel Module functions
If you have Devel Module installed (and enabled), it provides several functions for pretty printing. Good functions are
dpr()anddvr()which check to see that the user has admin permissions and then do a<pre>wrapped print_r() and var_dump() respectively. This means that non-admin users won't see the "goop" when you're working on the live site. But of course, you're not working on the live site are you?!? ;-) Better yet are thedpm()anddvm()functions which put their output into Drupal's $messages output for your theme. This keeps the output from printing before the HTML and making many themes go nuts. It's too late in the page life cycle to use dpm() and dvm() in page.tpl.php or the 'page' case of _phptemplate_variables() (the output won't show up 'til the next page load), but they're pretty groovy used anywhere else!gr8 list!
thanks!
HelpTip module
One of the often overlooked modules I use in every site I release, is HelpTip (might be because it's never really progressed beyond a development release for Drupal 5).
Perfect for Tip #1, while giving the user the extra choice of not seeing the same helptip again.
If, like me, you use a base database for every project, Help Tip saves a lot of time on initial "How To" emails for new clients et al (I'll get my head around install profiles one day... I promise)
Admin Role
For number 3, a much better solution is the adminrole module
Admin Role
For number 3, a much better solution is the adminrole module
Number of Grid View Columns
Hello, you have posted that it's possible with the custom argument handling code in a view to change the number of columns. I can't figure out how to do that. I want in one view with only three instead of four columns. How that works? Thanks for any help or links.
Very good Podcast and really
Very good Podcast and really useful!
greetings
I prefer Admin Menu to
I prefer Admin Menu to SimpleMenu for my administrative menu.
+1 for Admin_menu
Thanks for the tip - this is a real time-saver.
Archival Podcasts?
The tips and information on this site is amazing, especially while still learning so much about Drupal. Is there any way to get an archival podcast feed so that those new to here can get the podcasts in a much cleaner and informative list instead of just downloading LullabotPodcastNoXX.mp3 into folders? It'd be a huge help!
Awesome!
The Lullabot podcasts are always good and interesting, but this one.. wow! Sooo useful! Even for the ones I have heard about before it is a reminder that I should not forget about them simply because they make life so much easier. Even the "developy" tips that cannot be explained well in a podcast serve as excellent pointers.
Thank you very much indeed, Angie, James and Jeffs! Please clone yourself and let the clones make a Screencast of every single tip ;-).
Great tips
but please keep music down, the volumen is so high!! so the music fight with the voice :( and please dont use enya hehe.
Music: From 00:05 to 00:35?
Are you referring to the Lullabot podcast themesong which plays for 30 seconds in the beginning? It does go away after the first 30 seconds, so if you heard Enya, it was coming from some other source. The podcast themesong was written and performed by Jeff Robbins.
I tried the print_r($view)
I tried the print_r($view) tip but i dont get it to work. Great tips though!
Use drupal_set_message with print_r to see the view code
Specifically, put this in the custom argument code:
drupal_set_message('<pre>' . print_r($view, TRUE) . '</pre>');To do this on a live site without regular folks seeing, while you're online as user #1, you can use this:
global $user; if ($user->uid==1) drupal_set_message('<pre>' . print_r($view, TRUE) . '</pre>');(Note: Agaric Design Collective would never, ever, ever do debugging or development on live site. Ever. Well maybe sometimes.)
I'm glad jochen said print_r didn't work for him either. It must be called so deep in Views code it doesn't show up!<
wow. it works. thanks
wow. it works. thanks benjamin!
And the answer to the grid column question
since this page is already coming up high in searches for the subject!
$view->gridcount = 2;In Argument Handling Code's "Argument Code:" will set the number of columns to two.
(Agaric's notes on finding this)
Much appreciated
This was a very useful podcast for someone trying to develop their Drupal skills.
Partititioning your Podcasts into small sessions
I really like your podcasts and intend to listen to them all. Recently I received an Apple Ipod shuffle and download this podcast and others. Problem is that when I push the button to go to the next podcast, it takes an eternity and I ahve to listen to see when I am on the next podcasts.
Possible Solution: Can you all think about doing the following:
1) Give users upfront an itinerary of when subjects will be discussed. For example, "in the first 15 minutes we will discuss all 17 Drupal admin and configuration tips." In the next 15 minute segment we will discuss, Drupal.org tips, etc etc
2) Ideally, create a unique podcast for each major section of the podcast, i.e. tips for Drupal admin and configuration, then another for Drupal.org, views, theming, etc.
I think this would really be appreciated by the community and really go along way to achieve your goals of educating and entertaining novice and seasoned drupal users as well. Thanks for giving this some thought, have a Happy New Year
Full text summary - let's make it a tradition.
It's great that this podcast is having a full textual summary - please make it a tradition.
I really like your podcasts, but sometimes they are very length and I find it very much more practical to read the text when I am in front of the computer.
Also, it might be possible to create a table of contents for the main subjects discussed, e.g. (Minutes:Seconds):
0:30 - Intro and General news
12:17 - Taxonomy context
15:30 - Taxonomy breadcrumb
Then people will be able to start listening from the exact minute, yet download the whole podcast.
Amnon
Tip 25 Rocks!
Hey, I'm really digging tip #25, "Set up a wireframe & show the HTML output to your web designer." Any links on how to best utilize this? What should be included? Thanks! -NP
When does each tip starts?
This is a great podcast. But what if you need to jump to a specific tip?
Here is the exact times when each tip starts:
Drupal admin & Config trips
#1 - 6:15, #2 - 8:00, #3 - 8:45, #4 - 10:15, #5 - 12:12, #6 - 13:10, #7 - 13:50, #8 - 15:30, #9 - 16:40, #10 - 17:50, #11 - 19:55, #12 - 21:25, #13 - 23:00, #14 - 24:25, #15 - 25:55, #16 - 26:25, #17 - 28:30
Drupal.org
#18 - 29:55, #19 - 31:20, #20 - 32:00, #21 - 33:20, #22 - 35:10, #23 - 35:50, #24 - 36:30
Theming - 37:45
#25 - 38:05, #26 - 39:35, #27 - 40:25, #28 - 41:00, #29 - 42:15, #30 - 44:30, #31 - 45:25
Views
#32 - 46:30, #33 - 48:10, #34 - 50:10, #35 - 52:00, #36 - 54:20, #37 - 54:45, #37.5 - 56:16
Javascript
#38 - 58:00, #39 - 59:15,
Drupal Development and Coding - 59:40
#40 - 60:05, #41 - 62:45, #42 - 65:10, #43 - 67:35, #44 - 68:20, #45 - 70:10, #46 - 71:40, #47 - 73:00, #48 - 74:20, #49 - 75:15, #50 - 76:00
sweet
thanks for the index! brilliant.
Tips #4/Tip #28 Alternatives, Tips#30 use.
Regarding your focused drupal search suggestion (tip#4), we can also create a google CSE. Here is my Drupal CSE - done for Drupal Israel. It's much better then a simple google search and yet it's not limited to Drupal.org.
Regarding tip #28 - (41:00) - Another great way to beautifully print vars is to use the devel module's dprint_r function. One advantage is that it puts everthing in a scrollable DIV, so your theme is kept whole.
#30 (44:30) is a cool trick! format_interval seems like a great place to look on how to change the way dates are formattted for foriegn languages - a lot of customization is needed there. Sometimes, the order of date interval strings in foreign languages is completely different then on English - this post remedies that.
Hi guys, Perfect, keep up
Hi guys,
Perfect, keep up the good work. it's very useful and also lots of fun ;)
Thanks
Great tips
Some even the so called experts (me included) were aware of. Thanks for this list!
Very nice tips, good work.
Very nice tips, good work.
Tip 25 Rocks!
Thanks for the tip - this is a real time-saver.
drupal
pretty cool tips, i just downloaded the 6.2 version and set up a blog on my site. it's awesome. blog
Thanks
Thanks a lot for your great list.
It ist absolut helpful for a newbie like me.
Great!
Greetings from Europe.
Thank Lullabot!
Thank Lullabot!
Use Drupal has become even easier.
top notch stuff
So glad there's plenty of Drupal help available.
Well done but don't stop now.
How to Set Up the Firefox Bookmark (Tip Number 4)
I had to figure this out by doing a little research, but here's how you do number 4:
http://www.google.com/search?hl=en&q=site%3Adrupal.org+%s
(The "%s" is where your search term goes.)
Thanks Lullabot
Thanks alot for these great tips really!
I have benefited so much from them.
big thanx
big thanks for public those tips, they're awsome, thank you one more time
You have compiled a really
You have compiled a really good resource list.And that must have taken a lot of your valuable time! I thank you for the list and your effort.Do keep building similar lists as this one.
Thanks
Great job, thanks!
Great job, thanks!