Update: appparently, today was the day to write about this. Nedjo Rogers submitted a handbook page that shows a different method of achieving the same end.
For the most part, Drupal 4.7's block system is underutilized. This is a shame; with the proper templating, drupal's block system can become a valuable workhorse. In this tutorial, you will learn:
By the end of this tutorial, you will have the ability to place blocks into node's like a so:
If you are like me, you've been pulling your hair out trying to make teasers work in CCK. Well, as it so happens, I figured out a crazy simple phptemplate method of making CCK body fields act like any other node's body. Observe:
<?phpfunction _phptemplate_variables($hook, $vars) {global $user; switch ($hook) { case 'node': if ($vars['field_body'][0]['value']) { /* Believe it or not, all you have to do is pass the field through the existing node.module function node_teaser()! */ $vars['cck_teaser'] = node_teaser($vars['field_body'][0]['value'], $format = NULL); } break; } return $vars;}?>
<div class="content"> <?php //for teasersif ($page == 0) { print $cck_teaser;} //for fullpageselse { print $node->field_body[0]['value'];?>} ?></div> As you can see, these menu links have unique icons. Yet another miracle accomplished using Drupal's PHPTemplate. This technique is especially cool because it automatically generates CSS ID's from the menu link's name.
<?phpfunction phptemplate_menu_item($mid, $children = '', $leaf = TRUE) { return _phptemplate_callback('menu_item', array( 'leaf' => $leaf, 'mid' => $mid, 'children' => $children ));}?>
Now create a menu_item.tpl.php file.
There's good news and bad news. First, the good news: overriding theme functions is easy. The bad news: every theme function is different, and there isn't a standard proceedure of going about it; if you don't know what you are doing, its quite easy to accidently do something ugly, or foolish.
So, in the next few tutorials, we are going to explore the hows, whys, why nots, and what ifs of overriding theme functions. Each of these functions will present a different set of challenges, and opprotunities to do something stupid, etc. Today's lesson is "Building a better node form". In this tutorial you will learn
Drupal's phptemplate is the most powerful, simple, and flexible templating/theming system on the planet*. Yet, it seems that the majority of drupal themers, (and wannabe drupal themers) are ignorant of its true power.
More disturbingly, vast numbers of people still insist that Joomla!, typo3, and wordpress's templating systems are easier, sexier, and slicker. These people are either loony, or wrong.
As an expert in PHPtemplate (isn't that scary), I've decided its my duty to show the true power of PHPtemplate to world.
Consider these tutorials, a proper (and steadily growing) introduction to drupal's templating system.
In this first tutorial, you will learn how to:
Moreover, I will show you how bloody simple it is. Folks who follow this tutorial should already have:
Overriding is always done in the theme’s template.php file (if you don’t have a template.php file, you may create a it now). Obviously, before you can override anything, you must first locate what you are trying to override. The best way to do this is to search a module for the $form variable.
Michael Angeles' post on creating different looks for different sections by switching body classes and ID's inspired me to write up a related method.
The advantages of this method are that it dynamically builds classes on the basis of vocabulary and term that allow you to have wildy different styles for every node.
This method requires two parts, one snippet in your template.php file, and a special body tag in your page.tpl.php file.
Ah, chickens -- delicious chickens. Its a timeless truth, however, that not all chickens were born equal. And clearly, the best tasting chickens are those who've been allowed to feed, graze, and socialize on the open range.
Alas, this is not a white paper on the art of raising free-range chickens. Rather, its a tutorial on raising free-range node.tpl.php links such as "add new comment", "read more", or any other link which the multitudes of modules spew forth into that disgustingly generic $links variable. By the end of this tutorial you will no longer be limted by the $links variable. Instead, you will have the necessary code and knowledge to turn any link into a variable that you can place at any point in your node.tpl.php file.
Recent comments
2 weeks 17 hours ago
2 weeks 1 day ago
2 weeks 1 day ago
2 weeks 1 day ago
2 weeks 3 days ago
2 weeks 3 days ago
2 weeks 3 days ago
2 weeks 3 days ago
2 weeks 3 days ago
2 weeks 4 days ago