由 wanganqi 于 星期日, 08/16/2009 - 06:47 发表
Lullabot 汇总了50个drupal建站及使用技巧,这个技巧汇总写得非常得简略,大部分东西都是一带而过,对于初学者来说,很多条目是难以理解得。其中有很多有价值的东西只得我们去深入的探讨一下,但是在能够深入探讨之前您必须首先多drupal前端和后台管理页面有充分的熟悉。之前的Drupal建站教程大全是您的在读下面文章之前的必修课,建议研读。下面列出了引用自Lullabot team的“50个drupal设置和建站技巧”。之后我们会对大部分其中涉及的技巧进行深入的探讨,当然也不局限于这个列表。
Drupal admin and configuration:
Drupal.org
Theming
Views
JavaScript
Drupal Development and Coding
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. Also api.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!
- <?php
var_dump ( get_defined_vars ());
?> inside any template file to see what variables are available. - 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 <?php
drupal_add_js (array( 'my_module' => array( 'my_string' => t ( 'My string' ))), 'setting' )
?> Get translated strings from javascript: Drupal.settings.my_module.mystring - Same with urls: <?php
drupal_add_js (array( 'my_module' => array( 'my_url' => url ( 'node/10' ))), 'setting' )
?> It's more reliable and less work than using $base_path and Clean URL 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 !