Username Password
Bookmark and Share


    Package WebGUI::Macro::RecentPosts

    Macro for displaying the latest X posts in one or more collaboration systems.

Usage: ^RecentPosts(assetId,templateId [,numPosts,orderByField,descendingOrder,summaryField,dateField])

Available template variables:











post_summary (if you pass the optional summaryField argument)  


  process ( assetId,templateId [,numPosts,orderByField,descendingOrder,summaryField,dateField] )
    process takes 2 required parameters and 5 optional ones.

    The assetId of the parent of the collaboration system(s) from which recent posts should be pulled. If only pulling from one CS, you can specify its assetId directly.

    The templateId of the template the recent posts should be displayed in.

    The number of recent posts to pull; default is 3.

    The name of the template variable to order the posts by; default is none.

    If set to a true value (i.e. 1), posts will be in descending order.

    The name of the field to use for the summary; default is none.

    The name of the field to get the date of the post from; default is dateSubmitted.

System RequirementsPlease be advised: this contribution was tested with something older than WebGUI 7.5. When this contribution was uploaded there was no field for the author to fill out regarding it's requirements.
2johnatan.archer: "Hi!
Unfortunately, I can't get this to work. I copied it in the Macro directory, enabled it in mysite.conf and restarted apache.
I created a new template with the Macro/RecentPosts namespace (a blank template; which variables should go in there?) in the root/import/macro/recentposts directory.

Then I created a test page layout and put the macro call in the description field: "^RecentPosts(assetId,templateId);" where assetId is the ID of a specific collaboration system, and templateId is the ID of the template  I previously created.
The result is just a blank"
2cap10morgan: "
Sorry to hear you're having trouble. The relevant portions of my template look like this:

<tmpl_loop postLoop>
<h3><a href="<tmpl_var post_url>"><tmpl_var post_title></a><tmpl_if post_date><span style="font-size: smaller;">
<tmpl_var post_date></span>

<p class="report_summary">
  <tmpl_var post_summary>


4johnatan.archer: "Yeah it works! Many thanks!
I hope it'll make it into the"
4johnatan.archer: "I'm trying to display the thumbnail image of each post but the  dosn't seem to work with the"
4johnatan.archer: "After several tries I looked at the code and it seems that available variables are coded there. I added this line of code 'post_thumbnail' => $post->getThumbnailUrl, above line 94 and it"
2cap10morgan: "Thanks for the contribution! I'll add that to the module and re-attach it to my original post."
4johnatan.archer: "Thanks to you for this indispensable macro. Strange that there is RandomThread and not that one into the core :)

I would like to have other useful CS template variables included in the macro like user, replies, date, etc (pretty much the variables that are in the Weblog CS"
2cap10morgan: "
OK, the one attached now has the post_thumbnail template variable in it.

Feel free to add all the variables you want, and I'll review and add them to my WebGUI core submission version.

I still need to finish the i18n and help files to get it reviewed for core, but I hope to do that this week.

2TheSeparator: "

We tried to use the macro in the following way:

(assetId en templateID are correct only for us of course) 

&#94;RecentPosts( HytmZm4QvvoLyuQanzlIIQ,nMogPt6SBvXKdTQCE_1uDg);

 However an error message appears in Webgui.log:

2007/02/24 16:41:04 - ERROR - - main::[[undef]] - Processing failed on macro: &#94;RecentPosts( HytmZm4QvvoLyuQanzlIIQ,nMogPt6SBvXKdTQCE_1uDg);: Can't call method "getLineage" on an undefined value at /data/WebGUI/lib/WebGUI/Macro/ line 75. 


Where do we go wrong ?


Appreciate your reply,




3TheSeparator: "
Found the problem, there was a space before the assetID.........

Works fine now, exploring the possibilities ! 

Thank you for the contribution,



4cap10morgan: "Glad you worked it out. Let me know if you run into any problems.
2kmaclean: "
Greate macro!

To get this to work with WebGUI 7.4.20, I had to modify as follows:
     my $dateField = shift;
    # !!!!!!
    #$dateField ||= 'dateSubmitted';
    $dateField ||= 'revisionDate';
    # !!!!!!
    my %var
I think the "dateSubmitted" field was changed to "revisionDate" somewhere between the 7.3.22 to 7.4.20 version upgrade.


0cap10morgan: "NOTE BEFORE DOWNLOADING: This macro has performance problems and should really be replaced by the Asset Report, a much more user-friendly and generic way to do this sort of thing.

If you like and use the RecentPosts macro, please put karma into this RFE so we can get the Asset Report included in core:"
0rihab: "Speaking about performance would it enhance the performance if we select only published,approved Threads in the rules sent to getLineage method instead of getting all the descendant assets? "
0rihab: "Speaking about performance would it enhance the performance if we select only published,approved Threads in the rules sent to getLineage method instead of getting all the descendant assets? "
LinksNo Support Offered
Statistics Downloads: 1129
Views: 6086
Rating: 3
Updated: 2/28/2007
Keywords macros
NavigationBack to the Bazaar
© 2023 Plain Black Corporation | All Rights Reserved