I would like to show my users the latest message posted in a block. This block wouldn't auto update, just show the latest at time of page load. Is it possible to do this? Thanks.

Comments

SeeSchloss’s picture

Status: Active » Fixed

In 2.x you can use the tribune_get_last_posts($node, $nb) function to retrieve the $nb latest posts from the tribune $node. It is get_last_posts($nb) in the 1.x version of the tribune module.

So your block's code could be something like

$tribune = node_load(42); // or whatever your tribune's nid is
list($post) = tribune_get_last_posts($tribune, 1);

print theme("tribune_post", $post, $tribune);
 // or print yourself each member of $post (which is an associative array) that you want to display
 // like « print $post['login'].': '.$post['message'] », whatever

I mark this as fixed, but tell me if you have any issue with that

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Flying Drupalist’s picture

Category: support » feature
Status: Closed (fixed) » Active

Thank you very much. I want to avoid the php filter if I can, but still give admins the ability to choose what node to get such a message from.

I'm humbly requesting a block from where the admin can choose the node from an interface. Thanks.

SeeSchloss’s picture

Assigned: Unassigned » SeeSchloss

I have added a "readonly" checkbox to the blocks settings, so now you could add a block and choose the tribune node you want to display, "1" for how many posts to show, and check readonly to avoid showing the form for posting messages. The CSS and JS will still be included as they may be necessary depending on the filters you have enabled.

Is it the kind of feature you wanted ?

Flying Drupalist’s picture

Thanks, but not exactly, because it's still reloading. Can you also add an option to make it not refresh?

Thanks.

SeeSchloss’s picture

Status: Active » Fixed

Okay, I have also added a "reload delay" setting, so you can set it to 0 and it won't reload anymore.

Anything else ? :)

Flying Drupalist’s picture

Thanks a lot! :) You're the best. :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.