Drupal module: taxonews

Submitted by Frederic Marand on

I've written a module for drupal, to allow sites to display a number of blocks with latest stories by taxonomy, and automatic content expiration. Enjoy.

Whilst working on the helpdesk module, I found that, for another site, I had a need for blocks containing teasers of node matching terms in a taxonomy vocabulary, as links to the nodes themselves, with automatic content expiration based on publishing date.

After a few days as independent custom blocks, I found it more valuable to have these blocks integrated as just deltas in a single module, to reduce code bloat, and wrote this module, which I called taxonews (taxonomy-based news).

Salient features are:

  • Very small, low code volume, less than 200 LOC, works with basic Drupal 4.6.x
  • Does not modify the default 4.6.x database (unlike taxonomy block), which serves a mostly similar purpose.
  • Just two settings:
    • one for the vocabulary used as the basis for node selection
    • the other one for node lifetime

The module defines one block for each term in the selected vocabulary. They can then be configured individually from the standard admin/block page.

It will be on CVS as soon as I can get into it. In the meantime, it is available on taxonews section on the Audean wiki, and has a page on drupal.org at http://drupal.org/node/34460.

The code for this module is Open Source, licensed under the GPL version 2. As always, any relevant documentation is licensed under the Creative Commons Attribution-ShareAlike 2.0 France License.

It's kind of funny to think that helpdesk was supposed to be my first effort to create something on top of Drupal, as something very simple I normally write in Paradox in a couple of hours, or in Delphi or raw PHP in a couple of days, and it's not yet done after 12 weeks because learning how to code it on top of the Drupal framework mean much more work than I had envisioned initially, while in the meantime, I now code such "more natively drupalish" things as this module in a few hours while essentially working on something else.

I can't but wonder whether an ulterior release of the helpdesk module will see me restructuring it more elegantly around the drupal APIs...

Ramdak (not verified)

Mon, 2005-12-26 07:10

Hi,

This is a very useful module and I am using it for a site that will go live shortly. I was most happy to realise that it generates blocks for every individual term.

I have some feature requests:

1.) In the settings page, the module seems to pick up the vocabulary description also. This makes the drop-down box very long horizontally. Please consider listing just the vocab names.

2.) Please consider another setting to have the option of choosing the exact terms for which blocks should be generated. This would be very useful in situations where only or two terms from a vocabulary need to be used. For example, in a vocabulary for my site, I only need the 'Alerts' and 'Reminders' terms to generate blocks, but I have about 20 blocks generated nevertheless and cluttering the page.

3.) Will it be possible to automatically avoid displaying the block if it does not have any time-tagged content?

Thank you once again for a very useful module.

Ramdak

Thanks for your comments. Here are some answers:

1.) I thought you wanted to remove the name of the module, which is there so that blocks are grouped together on the admin/modules page, to avoid having blocks all over the place. As this was a minor fix, this setting is now enabled in the latest version. But this is not what you asked: for the need you describre, I think the best fix is to keep the vocabulary description short. It doesn't serve many purposes to have a long vocabulary description anyway, but sites can have a rather large number of vocabulary names, not always very explicit, so having the description is more useful than not having it. If it worries you, just go to function taxonews_settings (), look for the line that goes:

   $arVoc[$o->vid] = "$o->name - $o->description" ;

... and remove the - $o->description part.

2.) For this I'd rather suggest you use a specific vocabulary for just that purpose. It is usually a bad idea to use the same classification dimension (i.e. vocabulary) for more than one purpose.

3.) I'm not sure what you are requesting: currently, if a block has no nodes, it will be selectable in administer/blocks, but won't display anything and the content will start appearing when matching nodes are created. Would you like not to appear in Administer/Blocks ? I've added a setting for this in the new version, but I'd really advise against using it to disable empty blocks: this will shift block numbers when new content is content nodes are created and classified under terms that previously had none: taxonews block numbers will slide.

Thanks. Let me clarify:

1.) I actually like the blocks being named 'taxonews/block-name'. It is a fine usability feature that makes life easier for the admin. However, thank you for adding the setting to disable it if necessary. For the vocabulary description, I will follow your suggestion to remove from the code.

2.) You are right about using one vocabulary for one classification dimension. In my example above, 'Alerts' and 'Reminders' are actually terms of a vocabulary called 'Network'. This is a site for a large non-profit network. Since networking is the central focus of this non-profit, I have put all terms that have a networking dimension under one vocab. Here is the entire vocab:

Network (parent term)
-- Requests (child term)
---- Contacts Needed (sub terms)
---- Educational Assistance
---- Emergency Relief
---- Event Sponsorship
---- Information Needed
---- Materials Needed
---- Medical Assistance
---- NGO Jobs
---- Project Funding
---- Services
---- Volunteers Needed
---- Other
-- Opportunities (child term)
---- Award Nominations (sub terms)
---- Call for Proposals
---- Competitions
---- Donations
---- NGO Vacancies
---- Project Funding
---- Purchase Offers
---- Volunteering
---- Other
-- Alerts
-- Reminders
-- Achievements
-- Awards
-- Condolences
-- Initiatives
-- Interviews
-- Partnerships
-- People
-- Testimonials

I read the taxonomy explanation you once wrote, so if you think this vocab could be structured better, I would be thankful for your suggestions.

3.) No, I didn't mean disabling it from admin>>blocks, but hiding it on the node or taxonomy term page if there was no content. Otherwise, it would look quite odd if the block was listed with just the title and without any nodes.

4.) Lastly, it would be great if you could consider adding a per node setting for the number of days. Currently, the setting is for *all* the nodes in the block.

My humble suggestions for an enhanced taxonews module:

a.) Option for generating a block only for a specific term in a vocabulary

b.) On the node creation form, add either a drop-down of the vocabs selected at administer>>settings>>taxonews or a list of taxonomy terms with check boxes (if suggestion a.) is implemented) into which that node should go

c.) Add a 'hide/remove from block by date' setting for that node just like the scheduler module does, but without its complications of needing a cron job for that purpose. I like the way taxonews module removes the node from the block after the end of the scheduled number of days.

Thanks,
Ramdak

Thanks for your detailed explanation. However, it is easier for me if information/question about the software is located either directly on drupal.org (for helpdesk and G2) or on the wiki at http://wiki.audean.com/ for all modules (taxonews is not validated as a project on drupal.org). Would you mind registering on the wiki and adding your requests to the taxonews Wishlist page ? Thanks.

Note that:

  • for question (3), this is the default behaviour: blocks disappear if they have no matching nodes. I have added a per-block setting to the configuration yesterday, to force a default content in that case the admin so wishes.
  • for suggestion (b), this is the default node editing behaviour from taxonomy. module (taxonews does nothing here): all taxonomy vocabularies allowed for a given node type are displayed. Your question suggests you may not have added the node type you're adding to the list of allowed node types for the vocabulary (admin/taxonomy/edit/vocabulary/)), which is part of the taxonomy setup, not of taxonews.

Regarding the contents of your vocabulary, I can only imagine the content of your nodes, but at first sight I'd think that:

  • "People" and probably "Partnerships" are orthogonal to the rest of the vocabulary: all other terms are related to some form of action, while these can be the subject of these actions
  • If you're only using two terms, you'd probably do better to create an additional vocabulary just for taxonews display, with non-mandatory choice, and add two terms to it for these publishable news, and flag only the relevant nodes with one of these terms: the opportunity to publish anything is typically almost to the nature of the contents if you're not in the news business: it is more a matter of importance than of topic. Not forgetting that, by doing it that way, you can also push any node to a taxonews block if its contents are sufficiently important, just by flagging it with one of the terms in the publication vocabulary.

Apparently, this is a consequence of the revamped project/cvs integration on drupal.org : sandboxed modules can no longer have a project page.

I suppose I'll have to either make it a full-class module or remove it. In the meantime, you can get it from CVS. You can browse to it
here.

I tried to email it to you, but your address is unknown.