I would like to know what would be the easiest way to implement a block listing company news. The block needs to display the date and title of the news node. And the title must be click able to the full node.

I have looked at the Simplenews and Taxonomy Block modules. The one that almost doest what I want is Taxonomy Block. All I need to add is the date.

What module is the best the implement this or should I use flexinode with custom php block.

Example of what I am looking for (HOOPS NEWS) http://www.mbr.org/

Please help,
Thanks

Comments

budda’s picture

How about checking out flexiblock module? i've not used it but maybe it can help?

--
www.bargainspy.co.uk | www.mobilebeat.co.uk

NaX’s picture

Sorry, flexiblock is a very cool module, but it is for placing blocks. I want my news block to be placed in the left side bar, so that would make its placement just like a regular block. It is the content of that block that is important to me. It is like the resent blog entries block just it must also have the date the node was created and be ordered by date descending and link to the full node.

Uwe Hermann’s picture

If Taxonomy Block does what you want, I'd rather hack that to display the date, than create your own PHP bock (which will probably be more work)...

Uwe.
--
hermann-uwe.de | crazy-hacks.org | unmaintained-free-software.org

NaX’s picture

I try to keep the hacking to a minimum to make upgrading later easier. But if hacking is the best way then that is what I will have to do. I was just hopping a module could do it. It is sutch a simple thing that I am trying to do someone must have needed this before.

Look at the open office home page http://www.openoffice.org/. On the left there is block titled In the media that is exactly what I am looking for. Not that OpenOffice uses drupal but that is an example of what I am trying to do.

I am currently digging through the code of the Taxonomy Block module, I just cant find the function that builds the contents of the blocks

Thanks

rport’s picture

Perhaps you could create a new block with a custom snippit such as the ones listed in PHP page snippets: putting dynamic content into your main page.

The other option is to create a company news blog, then syndicate the content in a block in your own main page.

Russ

NaX’s picture

ok I hacked the taxonomy block module and now it does what I want. I think the taxonomy_block_get_block function should be themeable. If it was themeable it would have made my life a lot easier.

Thanks

Uwe Hermann’s picture

OK, submit a feature request (or even better: a patch).

Uwe.
--
hermann-uwe.de | crazy-hacks.org | unmaintained-free-software.org

NaX’s picture

There is alread a feature request. Some one beat me to it.

JimK’s picture

Your problem and solution sounds like what I've been looking for in my site: news with date block. I'm assuming you are making story nodes with the category "news" and then wanting them listed in the taxonomy block with date and such, right?
www.cpnhelp.org

NaX’s picture

You can see the final outcome here: http://www.blake.co.za

What I did was create a content type called company news and created a Vocabulary for that block and assigned that vocabulary to the company news content type.

Then I created my Company News taxonomy block.

Ok thats the normal stuff.

The Hack.
In the taxonomy_block.module file (ver 4.6.3), lines 231 – 246 inside the taxonomy_block_get_block function

From this

    $nodes = db_query(db_rewrite_sql('SELECT DISTINCT(n.nid), n.title, n.body FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE t.tid IN (%s) AND n.status = 1 ORDER BY sticky DESC, created DESC LIMIT %d'), implode($tids, ','), $result->length);

    $block['subject'] = $result->name;

    while ($node = db_fetch_object($nodes)) {
       $x++;
       $content .= '<div id="'. $x .'" class="'. (substr(decbin($x), -1) ? 'flip' : 'flop') .'"><h2>'. l($node->title, 'node/'. $node->nid,  array('title'=>t('view all'))) .'</h2>';
       if($result->teaser) {
         $content .= strip_tags(substr($node->body, 0, $result->teaser) . (strlen($node->body) > $result->teaser ? '...' : '')) .'</div>';
       }
       else {
         $content .= '</div>';
       }
    }

    $content .= '<div class="more-link '. (substr(decbin($x), -1) ? 'flip' : 'flop') .'">'. l(t("more"), 'taxonomy/term/'. implode($tids, '+'), array("title" => t("View all."))) .'</div>';

To This

    $nodes = db_query(db_rewrite_sql('SELECT DISTINCT(n.nid), n.title, n.body, n.created FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE t.tid IN (%s) AND n.status = 1 ORDER BY sticky DESC, created DESC LIMIT %d'), implode($tids, ','), $result->length);

    $block['subject'] = $result->name;

    while ($node = db_fetch_object($nodes)) {
       $x++;
       $content .= '<div id="'. $x .'" class="'. (substr(decbin($x), -1) ? 'flip' : 'flop') .'">' . format_date($node->created, "tiny") .'<br /><h2>'. l($node->title, 'node/'. $node->nid,  array('title'=>t('view all'))) .'</h2>';
       if($result->teaser) {
         $content .= strip_tags(substr($node->body, 0, $result->teaser) . (strlen($node->body) > $result->teaser ? '...' : '')) .'</div>';
       }
       else {
         $content .= '</div>';
       }
    }

    $content .= '<div class="more-link">'. l(t("more"), 'taxonomy/term/'. implode($tids, '+'), array("title" => t("View all."))) .'</div>';

Line 231
In the sql I added n.created, so I can have a date. Then I just modified the html that gets outputted to my likings.

Line 237
Added . format_date($node->created, "tiny") . (also hacked the format_date function to add tiny as a format type).

Line 246
Changed View all to more (could have used locale module)

The format_date function is in the includes/common.inc file starting at line 852.

I add

    case 'tiny':
      $format = variable_get('date_format_tiny', 'd/m/Y');//
      break;

Under switch ($type) {“ after line 865.

The problem for me with the format_date function was that custom does nothing. If I had more time I would have maybe modified custom to accept the passed in values. Looking back at it now that would have been easier.

One thing is not 100% correct. variable_get('date_format_tiny', 'd/m/Y'); looks for a variable called 'date_format_tiny witch does not exist so it defaults to my value of 'd/m/Y'. I have not tried it but I think you can just say.

$format = 'd/m/Y';

'd/m/Y' is the formating for the php date function also see http://www.php.net/date

Hope that helps

fidot’s picture

Your site http://www.blake.co.za doesn't display correctly in Firefox 1.0.6.

The company news is shown in the left hand column, but below the main content.

Terry