How To Build A Personal Nodetracker

(Submitted Wed, 2006-09-27 01:50)

I've received a number of emails since the launch of What Would Drupal Do regarding my personal nodetracker (see the righthand side of the screen, towards the bottom). As a result, I made a post on the drupal.org forums offering to open the nodetracker up to the public, so that people could individually track their own nodes. There was a surprising lack of response, given the number of inquiries I'd received.

I figure there are two probable reasons for this.

1) People want to run a nodetracker on their own sites, not someone else's.

2) Some people were inquiring not because they want a nodetracker per se, but because they are simply curious about how it is set up.

So to satisfy those two groups of people, here is how it's done. It is really an extremely straightforward use of CCK, Panels, and Views. You will need CCK, Panels, Views, and the Views Bonus Pack installed. Drupal 4.7.x is assumed.

Step 1: Set up a CCK type

- At admin >> content >> content types, create a new CCK nodetype called "nodetrack".

- Add an Integer>Textfield field type called "nodeid"

- Add a Text>Textfield field type called "description"

I don't use the CCK Link module here for a reason. You have to go through hoops to extract just the node number from such a field. It is simpler in case like this to work with the node number as text. We will auto-generate our links as we need them.

Now head over to admin >> categories and associated enable a taxonomy vocabulary (or two) to be used with nodes of the type "nodetracker".

You can now create a content of the type "nodetracker" and plug in the drupal.org node id number, title, and a brief description. But we are just getting started. We need a block, and ideally, a full page display.

Head on over to admin >> views, and add a new view. Call it NodeTracker. Under the "Page" fieldset, click on the "Provide Page View" checkbox. Give it a URL alias like nodetracker. For the viewtype, select something along the lines of "Panels: Teasers, 3 Columns". That's the Views Bonus Pack magick. (Thanks merlinofchaos!)

In the "Block" fieldset, click on the checkbox next to "Provide Block". Give it a title, and choose how many node entries you would like to show up in your block view.

Leave the Fields and Arguments fieldsets alone.

Under filters, filter based on

  • Node: Type [IS ONE OF] nodetrack
  • Node: Published [EQUALS] Yes

Leave Exposed Filters alone.

In the "Sort Criteria" fieldset, add

  • Node: Created Time - Descending

Save your view.

Here's the Views export, to save you some time:

  $view = new stdClass();
  $view->name = 'NodeTracker';
  $view->description = 'A list of tracked drupal.org nodes';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = '';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'panels_threecol';
  $view->url = 'nodetracker';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '10';
  $view->block = TRUE;
  $view->block_title = 'Node Tracker';
  $view->block_header = '';
  $view->block_header_format = '1';
  $view->block_footer = '';
  $view->block_footer_format = '1';
  $view->block_empty = '';
  $view->block_empty_format = '1';
  $view->block_type = 'teaser';
  $view->nodes_per_block = '12';
  $view->block_more = '1';
  $view->block_use_page_header = FALSE;
  $view->block_use_page_footer = FALSE;
  $view->block_use_page_empty = FALSE;
  $view->sort = array (
    array (
      'tablename' => 'node',
      'field' => 'created',
      'sortorder' => 'DESC',
      'options' => '',
    ),
  );
  $view->argument = array (
  );
  $view->field = array (
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'content_nodetrack',
),
    ),
    array (
      'tablename' => 'node',
      'field' => 'status',
      'operator' => '=',
      'options' => '',
      'value' => '1',
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node);
  $views[$view->name] = $view;

Still with me? We're almost there.

Everything is set up, except that things are going to look really ugly. Trust me. Try it. Enable your block and take a look.

We need to theme our teasers. Now, this could probably be handled through the Contemplate module, but I'm a sucker for pain.

Create a file in your theme directory called "node-content_nodetrack.tpl.php". The filename is important. The "nodetrack" bit has to match what you named your CCK type, otherwise PHPTemplate won't know to use it for your node display.

Here's what my node-content_nodetrack.tpl.php file looks like.

<div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>">
      <?php if ($picture) {
      print
$picture;
}
?>


<?php
 
/* for teasers */
 
if ($page == 0) {
      print
'<div class="nodetracker_teaser">';
      if (
strstr($_REQUEST['q'], 'nodetracker') ) {
     
/* nodetracker */
     
print '<div class="' . $zebra . '">';
      print
'<small>(#' . $field_nodetrack___nodeid[0][view] . ')</small><BR />';
      print
'<a href="http://www.drupal.org/node/' . $field_nodetrack___nodeid[0][view] . '">' . $title . '</a><BR />';
      print
$field_nodetrack___description[0][view] . '<BR />';
      if (
$terms)
      print
'<span class="taxonomy">[' . $terms . ']</span><BR />';
      print
'<BR />';
      print
'</div><!-- zebra -->';
      }
      else {
     
/* default teaser */
     
print '<div class="' . $zebra . '">';
      print
'<small>(#' . $field_nodetrack___nodeid[0][view] . ')</small>';
      print
'<a href="http://www.drupal.org/node/' . $field_nodetrack___nodeid[0][view] . '">' . $title . '</a>';
      print
'</div><!-- zebra -->';
      }

      print
'</div><!-- nodetracker_teaser -->';
      }
      else {
?>


      <?php if ($submitted) { print '<small>'.$submitted.'</small><br />'; } ?>
      <span class="taxonomy"><?php print $terms?></span>

      <div class="content">
      <?php
     
print $content;
     
?>

      
      <?php if ($links) { ?><div class="links">&raquo; <?php print $links ?></div><!-- links --><?php } ?>
      </div> <!-- content -->
      <?php } /* end of else from beginning */ ?>
      </div> <!-- node -->

I think that got a tad mangled, but you get the idea. More about node.tpl.php files here

*Phew*

Now you can easily add your tracked nodes to your website, provide a block view, RSS feed, and have a nice three column page view complete with clickable taxonomy categorization.

Ta-da.

Submitted by bohemicus (not verified) on Wed, 2006-09-27 08:53.

Great tutorial, thanks. Of course, to make it complete, you would have to write a little bookmarklet to make it possible to submit to it directly from the Drupal site. The http://drupal.org/project/nodeformpopup module makes it relatively painless.

Submitted by Anonymous (not verified) on Sat, 2008-11-22 00:24.

Beautiful tutorial. I love it.

Submitted by drawk on Wed, 2006-09-27 16:59.

Interesting .. I wasn't aware of nodeformpopup. Something similar can be done with a javascript bookmark and the prepopulate module.

Yeah, I'll have to do a followup for the bookmarklet. The post was getting a little long and I figured I should wrap it up :)

UPDATE: How to create a bookmarklet for your node tracker

Submitted by Bedford car insurance (not verified) on Tue, 2009-02-24 01:48.

Yeah it is pretty similar to prepopulate module, but there are some small differences.

Submitted by all about annuities (not verified) on Tue, 2009-03-17 04:46.

I agree but the differences are hardly noticeable for me though.

Submitted by Joe Moraca (not verified) on Tue, 2006-10-10 00:23.

I had a problem with the theming -- I was expecting the nodetracker block to show the description field as yours does. Just coping and pasting the node-content_nodetrack.tpl.php didn't do that for me.

At first I thought it was a problem with the variable names but after using printr I found it was the if statement causing the top part to "not work" and going to the "else" part..

I had to copy
print $field_nodetrack___description[0][view]

into the

else {
/* default teaser */

part to get it to show up. It worked -- I have to say I don't really understand the logic in the if ... I am still a beginner at some of this stuff.

Anyway thanks for your how-to's I find them the best way to learn. Keep up the good drupal work.

Glad you found my blog webdevgeeks.com I use it as a bookmark site for things I want to work on more.

Submitted by admin on Sat, 2006-10-14 07:09.

One of the things on my to-do list (but flagged low priority out of necessity) is to clean up the code snippet in the post. Glad to see you got it sorted out to do what you were looking for.

I wonder if you're planning to make your nodetracker public. It would be interesting to see what other people are keeping track of.

Submitted by Martijn (not verified) on Wed, 2008-11-26 13:56.

Hi,

Why dont you make this into a module for drupal.org?'
Then I do not have to go through this tutorial, which is great by the way!

I notice that that will increase the response a lot!
(I am the module builder of node_forum D5 after great work of Eaton).
see www.trekking-world.com/nepal-forum for implementation

Greetings,
Martijn

Submitted by Car Insurance (not verified) on Mon, 2009-01-19 04:30.

Awesome tutorial. Clear and easy to understand. I'm still a newbie and this was really useful Ned to check it out in the night. And yeh, why not make it a module on drupal.org. Anyway, awesome stuff. A sure bookmark

Submitted by Kristi @ Low Book Sales (not verified) on Wed, 2009-02-04 03:18.

Great tutorial. I just switched to drupal and I had no idea about a nodetracker. Got the idea now. nice tutorial. Keep it up.

Submitted by UK Online (not verified) on Thu, 2009-02-05 05:01.

Great information. I'm planning to move to Drupal and wanted to do some research before moving. This article gave me some goo information and a reason to move to Drupal. Nice work. Thanks for the information. Cheers

Submitted by car (not verified) on Sat, 2009-02-07 14:55.

nice post thank you so much.

Submitted by Research (not verified) on Sun, 2009-02-22 15:19.

nice post and great information thank you very much.

Submitted by Shantaesunw (not verified) on Thu, 2009-04-02 21:25.

Hi people! why needs the diet? www.whatwoulddrupaldo.org I know a web-site where there is a first sign of menopause . I can give the link. diazepam tab 18350 - fm depression effexor other The mechanisms for the SSRI and platelet connection are still unidentified although they don't appear to inhibit platelet activity in the same way as some other known compounds." zithromax for child or and ]Catalog pharmacy 2009 carisoprodol use .G'night.

Submitted by automobiles (not verified) on Fri, 2009-04-03 09:33.

This is a very useful information.I'll surely try this
Thanks

Submitted by Online Colleges (not verified) on Fri, 2009-04-10 10:52.

Create a file in your theme directory called "node-content_nodetrack.tpl.php". The filename is important. The "nodetrack" bit has to match what you named your CCK type, otherwise PHPTemplate won't know to use it for your node display.

Submitted by Anonymous (not verified) on Thu, 2009-04-16 20:20.

very usefull info at this post thanks!!

Affiliate Promotion

Submitted by ghjhygdtuy7 (not verified) on Mon, 2009-04-20 11:39.

ghjhygdtuy7 ghjhygdtuy7 http://jygdttw.com [url=http://jygdttw.com]ghjhygdtuy7[/url]

Submitted by lyrics (not verified) on Wed, 2009-04-29 19:33.

A brief composition written or adapted for singing.
b. The act or art of singing: broke into song.
2. A distinctive or characteristic sound made by an animal, such as a bird or an insect.
3.
a. Poetry; verse.
b. A lyrics poem or ballad.
Idiom:
for a song Informal
At a low price: bought the antique tray for a song lyrics.

Submitted by Anonymous (not verified) on Thu, 2009-05-07 01:49.
Submitted by Anonymous (not verified) on Thu, 2009-05-07 01:50.
Submitted by Anonymous (not verified) on Thu, 2009-05-07 01:51.
Submitted by holo (not verified) on Fri, 2009-05-08 19:40.

شات الخليج
شات الحب
شات السعودية
شات
دردشه
دردشة
دردشة بنات
دردشة السعودية
دردشة عربية
شات صوتي
مكياج 2009
أزياء سهرة 2009
شات جده
شات الاحساء
شات الدمام
شات الرياض

دردشة صوتية
دردشة الكويت
دردشة الامارات
دردشة عمان
دردشة قطر
دردشة البحرين
دردشة العراق
دردشة اليمن
دردشة سعودية
دردشة كتابية
شات كتابي
عروس 2009

بنات
ترافيان
الرياض
فيديو
حواء
الخليج
افلام
وزارة التربية والتعليم
ماسنجر
قصص
ترجمة
الود
الشله
video
اليوتيوب
راشد الماجد

عكاظ
بلياردو
العربية
توبيكات ملونه
توبيكات 2009
توبكات
توبيكات 2009
توبيكات للبنات
توبيكات بنات
توبيكات رمضان
كورة
الوطن
قوقل
جريدة الرياض
اليوم
اغاني
سعودي

شات سعودي
سعودي
خليجي
عربي
منتديات السعودية
منتديات الكويت
منتديات الامارات
منتديات عمان
منتديات قطر
منتديات البحرين
منتديات العراق
منتديات اليمن
منتدى بنات
خدمات
مسجات
منتديات
منتدى
عالم حواء

العاب بنات
العاب فلاش
العاب
دليل
موقع
يوتيوب
جوال
الجامعات
YouTube
Business
online
Roro 44
برامج
حب
قصات شعر 2009

الحياة الزوجية
ياسر القحطاني
Mobile
university
Tourism
Travel
صور
ستار اكاديمي 6
online games
Internet
Directory
Free Download
Games

Submitted by ugg boots (not verified) on Wed, 2009-05-13 10:46.

A pair of jordan shoes or ugg boots? I think you prefer air jordan shoes cos a pair of basketball shoes can help you much in the match. However, someone may saying like this: hey, give me some

Submitted by Angeline F.Ray (not verified) on Fri, 2009-05-22 11:38.

Now ,I'll move to Drupal.Thanks for detailed information and for graet share.

Submitted by shower enclosure (not verified) on Fri, 2009-05-22 12:33.

really good blog thanks

jen xx

Submitted by car rental uk (not verified) on Fri, 2009-07-10 07:34.

Great tutorial! I am always looking for visuals to help walk me through various set ups, and this one was very helpful both in explanation and in visually gripping the premise. Thanks!!

Submitted by Anonymous (not verified) on Mon, 2009-07-20 22:27.

Very good info, great learning tutorial.

Hosted By Dreamhost.com