I am wondering if there is any way to flag a newly created node by taxonomy. Thanks.

Comments

pwolanin’s picture

you need to be more specific. Do you want all nodes created form this time forward to be tagged with a particualr taxonomy term? Do you just want to show a list of X nodes created in the last week? Show a list of the X most recent nodes? Apply a taxonomy term for a certain number of days then remove it?

All these things can be done (though you might have to write some code).

---
Work: BioRAFT

oweowe’s picture

Thanks for your advice.
My Web front page consists of 6 taxonomies (I use taxonomy block module). Each taxonomy shows the latest 10 nodes of that category.
Among all the nodes shown on my front page, I wish the nodes created within 7 days from today be flagged as "new" at the end of the node title.
I am wondering if there is any way to achieve this? Thanks!

pwolanin’s picture

Yes, I'm sure it's achievable. I'm not familiar with that module, however, so I can't be very specific. You'll have to delve into how the module displays he titles

Each node object should include a timestamp of when it was created ($node->created).

---
Work: BioRAFT

oweowe’s picture

This is the code I found in the Taxonomy Block module.

function theme_taxonomy_block_list_item($node, $teaser) {
  $output = '<li>' . l($node->title, 'node/'. $node->nid,  array('title'=>t("view {$node->title} in full") ));
  $output .= '<br/>' . $teaser;
  $output .= '</li>';

Would you please tell me how to update it, or give me a code snippet how to show the title plus "New" tag.

It is really appreciated!

pwolanin’s picture

look at the node table- there are two possible values you could use- either "created" or "changed". I'll assume "created".

So, the code is pretty easy if you rememebr that's we're working with timestamp values (# of seconds). The number of seconds in a week is 60*60*24*7.

Try something like this in your template.php file (assuming a PHPTemplate theme):

function phptemplate_taxonomy_block_list_item($node, $teaser) {
$is_new = (time() - $node->created) < 60*60*24*7;
$extra = ($is_new) ? ' <span class = "marker">new</span>' : '';
$output = '<li>' . l($node->title, 'node/'. $node->nid, array('title'=>t("view {$node->title} in full") )) . $extra;
$output .= '<br/>' . $teaser;
$output .= '</li>';

I looked at the code produced by tracker module for how it marks nodes as "new" so this can re-use the same CSS class. If you'd rather have this "new" look different, obviously you'll need to change the CSS class and your style.css file.

---
Work: BioRAFT

oweowe’s picture

It works!!!
Thank you very much!