background preloader

Drupal

Facebook Twitter

Node.tpl.php. Last updated October 12, 2010. Created by m1mic on October 21, 2004.Edited by silverwing, andrevock, ronald_istos, Jeff Burnz. Log in to edit this page. This template controls the display of a node, and a node summary. It can only affect the output of the $content variable. Available variables $content Node content, teaser if it is a summary.

$date Formatted creation date. $directory The directory the theme is located in, e.g. themes/garland or themes/garland/minelli. $id The sequential ID of the node being displayed in a list. $is_front True if the front page is currently being displayed. $links Node links. $main (4.6) True if the node is appearing in a context, like the front page, where only the teaser should be shown. $name Formatted name of author. $node (object) The node object. $node_url Link to node. $page True if the node is being displayed by itself as a page. $picture HTML for user picture, if enabled. $sticky True if the node is sticky. $submitted $taxonomy (array) $teaser $terms HTML for taxonomy terms. Theming nodes by content type. Note: To do this in Drupal 7 please see Drupal 7 Template Suggestions.

The file node.tpl.php is used to theme certain types of nodes. This single file generically covers all Content Types and you can edit it to make changes across the board as detailed on the node.tpl.php handbook page. To theme individual content types in different ways, you need to create a file node-[type].tpl.php in your theme's folder, where [type] is the machine readable name of the content type, for each type you wish to theme. Some examples: For Drupal 6 (Use -- for Drupal 7) node-story.tpl.php Themes only Story type nodes. node-page.tpl.php Themes only Page type nodes. Node-forum.tpl.php Themes only Forum type nodes. node-book.tpl.php Themes only Book type nodes. In general, you can replace [type] with any content type system name. Once you have this new file, copy in the contents of node.tpl.php and modify it however you wish.

This is also the case for subthemes. Drupal 6. Directory precedence and multi-site considerations. Directory Precedence Contributed modules and themes can also be placed in the directories /sites/sitename/modules/ and /sites/sitename/themes/. Often, the sitename will be 'default'. Contributions placed there will only be available to the named site, whereas those under /all/* are available globally. For a single site setup, this probably won't make much difference to you, but if you ever start modifying downloaded code for your own use, it's a good idea to isolate your changes from the clean versions.

It's possible to have two versions of any module (even core ones) available on the site. Also, you can place modules anywhere within subfolders underneath any of these /modules/ folders. Multi-site Considerations The steps for installing in a multi-site configuration are much the same. If you wish to limit the access to a module or theme to a specific site, then create a modules and/or themes directory under that sites folder. sites/example.com.site3/modules sites/example.com.site3/themes. Examples for Developers. Follow the Examples project on Twitter: The Examples for Developers project has a Gittip team page. You can contribute financially to the project: Code Examples For Drupal The Examples for Developers project aims to provide high-quality, well-documented API examples for a broad range of Drupal core functionality.

The Examples project contains many modules which hopefully illustrate best practices for implementing various Drupal APIs. Developers can learn how to use a particular API quickly by experimenting with the examples, and adapt them for their own use. Note also that these modules demonstrate internals for Drupal development in PHP (and some JavaScript). How To Use These Modules As Modules You can enable these modules just like any others.

API.Drupal.Org You can also browse the documentation generated from this project on api.drupal.org. Browse The Repo Adapt The Code Core Only How can you help? I'm glad you asked: Need a Drupal Expert? I get a lot of calls and emails for Drupal work. Often many more than I can handle. It's common for these companies to complain about how hard it is to find a "Drupal expert". So what can these companies do to find the right Drupal programmer for their project? First of all, what is a Drupal expert? Good question. Here are some things that someone with deep Drupal expertise should understand: 1) Basics - all the required things needed for installation and basic configuration such as setting up databases, clean urls, installing modules - this is the stuff that a junior Drupal developer should know how to do 2) Standard Features - most websites will require the typical Drupal modules such as cck, views and pathauto - junior to mid-level Drupal developers should know how to create content types with cck, create basic custom views, and configure pathauto So, now that you know what a Drupal expert should understand, where do you find one?

I've integrated code from these Drupal developers: Upgrading modules. Updating modules can be a more involved process than installing or removing modules. Follow the steps closely, as they are necessary to ensure the stability of your website. To update a module that's used by your website: Check for module-specific update instructions First, check the module's project page "Read Documentation" link, as well as the instructions (for example, README.txt, INSTALL.txt, and UPGRADE.txt) that come with the module's installation file (tarball or zip)for any module-specific update instructions.

This is typically necessary when updating modules that involve the usage of third party libraries. Be sure to read and understand all module specific requirements before proceeding with the updates. Back up your database and files Your website's database contains all of its content, as well as all of its settings and configuration. Put your site into Maintenance mode Replace the module code with the updated version Manually updating files Drush drush up [module] drupal up.

Modules

Pathauto. The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias. This allows you to have URL aliases like /category/my-node-title instead of /node/123 . The aliases are based upon a "pattern" system that uses tokens which the administrator can change. Requirements Versions The 7.x-1.x and 6.x-2.x branches are currently accepting new feature requests and are kept in sync as much as possible. The 6.x-1.x branch is feature-locked and will only add bug fixes and security updates if needed. Known issues Multilingual URL alias support is still a little unstable and should be tested before used in production. Recommended modules Redirect (D7) / Path Redirect (D6) when installed Pathauto will provide a new "Update Action" in case your URLs change.

Co-Maintainers Pathauto was originally written by mikeryan and maintained by Greg Knaddison (greggles) . Pledges Downloads. Drupal and OOP. Note: This page is about Drupal 7's (and prior versions') architecture. Drupal 8 changed a great deal and now uses actual OOP practices. Drupal often gets criticized by those who look to its source code and API expecting to find certain familiar aspects of object-oriented programming (OOP). For example, the word "class" does not appear in Drupal code as often as some might expect. Some have viewed this as a deficiency. Although Drupal does not make thorough use of the native OOP features of PHP, the Drupal code base and API does reflect some principles found in object-oriented programming and design. This article describes the architecture of Drupal from an OOP perspective, so that programmers familiar with OOP can evaluate Drupal in light of object-oriented design principles, and hopefully feel more at home in the Drupal code base.

Motivations for Current Design Back as far as version 4.6 of Drupal, the decision was made not to use PHP's class construct. OOP Concepts in Drupal Objects. Why You Should Use Drupal for Your Next Website Project. A couple of years ago Mark wrote about Drupal 6 Selling Points on the Digett blog. Since Drupal 7 is now mature enough to build sites upon, it seemed like a good time to look again at the reasons why someone would want to use Drupal to build a website.

Open Source Open Source means that the code used to run Drupal can be copied, modified, and shared with others. Anyone with the skill can download and use the Drupal code, make whatever changes they want, and send those changes out to anyone else, or even contribute the changes back to Drupal for others to use and share. The advantages of the open source model of software development are numerous: Free to download and use. Drupal Community While the above advantages will be mostly true of any open source project, some of the unique stats about Drupal are: Huge developer community: Nearly 1000 developers contributed code to Drupal 7. Drupal Features The Drupal CMS (Content Management System) has the following features: Drupal Websites. Structure Guide. Last updated April 28, 2015. Created on November 8, 2009.Edited by ifrik, pbulebar, silverwing, bekasu. Log in to edit this page.

Welcome to the Drupal Structure Guide. This guide provides comprehensive information on tools and techniques for organising the information architecture of a Drupal site. The guide shows you the fundamentals of organizing your content, making it easy to navigate, and allowing you to direct your users to relevant information. This book covers topics such as: Content typesNavigation menusBlocks Taxonomies Views Panels Who should read this guide This book should be read by: Information architectsInterface designersSite developers In other words, anyone who needs to understand the fundamentals of structuring a Drupal site should read this guide. For information on adding features to a site, see the Site Building Guide. Looking for support? CCK Videos. Drupal Videos and Tutorials. Clearing Drupal's cache. To create a page Drupal needs to make several database queries. This can slow down websites with a lot of traffic.

To make websites faster Drupal stores web pages in a cache. It is a good practice to clear caches when moving a site from one host to another. Clearing the caches can also useful when installing new modules or themes, and as a first step in troubleshooting. Note that there are sometimes caches other than the Drupal cache that can affect website performance. The procedure below is for clearing Drupal's internal cache. About clearing the theme cache. Clearing the cache The easiest way to clear the Drupal cache is to go to Administration > Configuration > Development > Performance ( Click the button "Clear all caches" Other ways of clearing the cache Drush Run drush cc all.About drush Run update.php Running update.php ( is another way of clearing the cache.

A PHP snippet In the database Devel module. Understanding Block System. Play Video Movie link (right-click to download)Problem with this video? Contact me Drupal's Blocks System is the partner to your site's content. Of everyting you see on a Drupal page, it's either content or something from a block. With the introduction of Views, you can pretty much say most every Drupal page is Content (nodes) and Blocks or a View (which is content itself) with - again - blocks. What may be confusing is the "Blocks" area of Drupal is actually the management of the available blocks within the defined Regions (Drupal 6 or Drupal 5) of the current Theme.

Quite simply, it goes like this. Theme > Regions > Blocks > Content Where content can come from a Module, an Embedded View or your own custom content. You get to control which blocks show, who gets to see them and on which pages. Drupal – Add Configurable Values to Block. Dispatching Drupal hooks | Tobias Sjösten. The word function implies its intended scope.

A function should strive to leverage exactly one functionality. If you are cramming more than that into your function, then you probably need to do some refactoring. I think Linus Torvalds hinted towards this quite eloquent. If you need more than 3 levels of indentation, you're screwed anyway, and should fix your program. One situation where I seldom can obey that rule of thumb is when implementing hook_block() in a Drupal module. That hook is first called once to fetch a list of your blocks. So how do we rectify this situation, besides whining about it and not submitting a patch? PHP has this feature named function callbacks which I really recommend reading up on if you are not familiar with it. Let us start with the hook implementation. So what goes on here? The next step is to implement our list and view callback. So there we go – three slim functions instead of a big, bloated one.

Customize a block. Hook_block. Declare a block or set of blocks. Any module can declare a block (or blocks) to be displayed by implementing hook_block(), which also allows you to specify any custom configuration settings, and how to display the block. In hook_block(), each block your module provides is given a unique identifier referred to as "delta" (the array key in the return value for the 'list' operation).

Delta values only need to be unique within your module, and they are used in the following ways: Passed into the other hook_block() operations as an argument to identify the block being configured or viewed.Used to construct the default HTML ID of "block-MODULE-DELTA" applied to each block when it is rendered (which can then be used for CSS styling or JavaScript programming).Used to define a theming template suggestion of block__MODULE__DELTA, for advanced theming possibilities. Parameters $op: What kind of information to retrieve about the block or blocks. 'list': A list of all blocks defined by the module.' File.

Drupal: How to render a block in the middle of a node. - Website Design & Development Blog - Web Design and Development - Winnipeg, Manitoba - Notion Design. In a recent project we needed to display a form amidst the regular text content of a node. By default, Drupal doesn't allow this behaviour. That's okay, by default, Drupal doesn't allow a lot of behaviour. But that is what makes Drupal a pretty cool CMS, it's very extendable. In order to display block content in the middle of our node, you'll need the following modules: When we're done, we'll be able to nest a token code into our body content and have it rendered as a block. Our token will look like: [token custom_module mytoken]. After installing the required modules, you will want to enable the token filter for the input formats you use for editing content. Token Filter is what enables us to embed token keys in our content. In our module "custom_module", we have the following block defined: function custom_module_block( $op = 'list' , $delta = 0) { $block [ 'content' ] = ' Hello World!

$block = module_invoke( 'custom_module' , 'block' , 'view' , 0); if ( $type == 'custom_module' ) { Theming Guide. Tepmlate diagram. Guide to overriding themable output. Theming Views 2. Core templates and suggestions. Core templates. 6 Template Suggestions. Default baseline variables. Structure of the .info file. Default .info values. Theming Videos. Theme-developer module - screencast. Theming Best Practices. Clean URLs. How do I unset the clean URLs? On backward compatibility: the drop is always moving.

Upgrading from previous versions. RESOLVED: Cannot log in after migrating to new server. Drupal 7 vs Drupal 6. Installing contributed modules (Drupal 5 and 6) Drupal 6 vs 7 Performance. 7 - Easier and more powerful than ever. 5 Frustrating Things about Drupal 7. 11 Things We Love About Drupal 7.