This site is not supported for Internet Explorer 6. It might look funny or even not function properly if you are using this browser.
You upgrade Flash as soon as they get a new version. Why not get an updated browser?
Try Firefox, Chrome or if you love and breath Microsoft than IE7.

Simple redirection of Drupal template files

This is a quick and super easy way to mimic the functionality of a content type in your Drupal install. On the site I'm working on we wanted to replicate functionality for two content types. Now the Drupal way would say to use the same content type and filter them with taxonomy or even a CCK field. In this instance the two content types currently offer the same functionality but there is reason to believe that in the future one will get a lot of changes or even a completely different layout then the other so it was decided to keep them separate.

Either way you decide to go this isn't about workflow. This is about how you can mimic the look of a content type without duplicating the code. To start we did duplicate the content type so all the CCK fields were implemented in content type #2. Once that was done we simply need to add a quick one line function to point the template for content type #2 back to #1.

In template.php add...

function theme_preprocess_node(&$vars) {
if ($vars[type]=='ctype2') {
  $vars['template_files'][] = 'node-ctype1';
}

That's it. Simple and easy.

Filed under:

No comments

Add your comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <br /> <br> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Images can be added to this post.

More information about formatting options

Mollom CAPTCHA (play audio CAPTCHA)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated.

Google Reader Shared Items

User login