I'm trying to create a block which will display the most recently added flexinode in a certain taxonomy term. The flexinode should be formatted so that it can be output using the usual <?php print check_output($flexinode->flexinode_field); ?> syntax.

Some people have done similar things, as at drupal.org/node/23231 or drupal.org/node/32272. However, nobody seems to deal with the peculiarities of the flexinode system, preferring to output the standard node fields (ie <?php print check_output($node->teaser); ?>).

Here's some code to give a more concrete idea of what I'm trying to do. Note the comments in the get_recent_flexinode() function.

<?php
  function get_recent_flexinode($tid) {
    /** a miracle occurs **/
    /** return most recent flexinode in the taxonomy term $tid  **/
    return $flexinode;
  }
  $flexinode = get_recent_flexinodes($flexinode_type, $tid, 1);
?>  

<div class="flexinode-field-1"><?php print check_output($flexinode->flexinode_1); ?></div>
<div class="flexinode-field-2"><?php print check_output($flexinode->flexinode_2); ?></div>

Extra credit to the person who can expand the <?php get_recent_flexinode($tid) ?> function to allow the specification of specific node types and to allow the function to return more than one node (for example <?php get_recent_flexinode($tid, $type, $list_length) ?>.

Any advice would be much appreciated. I'm stumped!

Comments

robomalo’s picture

For more related threads, see the following handbook page:
http://drupal.org/node/23220

There are quite a few suggestions of the "display (x) most recent..." type, however as far as I can tell, none deal with outputting flexinode content one field at a time.