Dashboard > blojsom > ... > Users Guide > Template Macros
  blojsom Log In   View a printable version of the current page.  
  Template Macros
Added by David Czarnecki, last edited by David Czarnecki on Mar 02, 2006  (view change)
Labels: 
(None)

The following template macros are available for use in your Velocity templates. They are available starting with blojsom 2.22.

For macros without parameters, you can simply use the macro as follows.

#MacroName()

For macros with parameters, pass in the required arguments to the macro as follows. The following assumes a macro with two parameters.

#MacroName($parameter1, $parameter2)

For a more detailed description of Velocity macros, you can visit the Velocity Macro section of the Velocity User's Guide.

Velocidocs

You might also want to check out the blojsom Velocity macro velocidocs. This is similar to the blojsom javadocs. All of the information on this page is available in the velocidocs.

Blog Information Macros

The following macros can be used to print out information about the blog itself.

Macro Description
#BlogName() Print out the name of the blog.
#EscapedBlogName() Escape &, <, >, ", and ' in the blog name and print out the blog name.
#BlogDescription() Print out the description of the blog.
#EscapedBlogDescription() Escape &, <, >, ", and ' in the blog description and print out the blog description.
#BlogURL() URL for the blog.
#BlogAdminURL() Administration URL for the blog.
#BlogBaseURL() Base URL for the blog. Useful for constructing links to resource files.
#BlogLanguage() Language code for the blog.
#BlogCountry() Country code for the blog.
#BlogOwner() Blog owner's name.
#BlogOwnerEmail() Blog owner's e-mail address.
#BlogDefaultFlavor() Default flavor for the blog.

Entry Macros

The following macros can be used to print out information about a particular blog entry or to set page variables depending on certain conditions.

Macro Description Availability
#Author($entry) Print out the author of the blog entry (if available).
#EntryCategoryName($entry) Print out the descriptive category name for a blog entry's category. If the descriptive name is not available, the category name is used.
#CommentsAllowed($entry) Creates a page variable $commentsAllowed if comments are allowed on an entry.
#DatelessFriendlyPermalink($entry) Creates a page variable $entryLink with a link to the blog entry of the form http://your.blog.com/blojsom/blog/category/permalink. blojsom 2.24
#TrackbacksAllowed($entry) Creates a page variable $trackbacksAllowed if trackbacks are allowed on an entry.
#PingbacksAllowed($entry) Creates a page variable $pingbacksAllowed if pingbacks are allowed on an entry.
#friendlyPermalink($entry) Creates a page variable $entryLink with a link to the blog entry of the form http://your.blog.com/blojsom/blog/category/YYYY/MM/DD/permalink. YYYY is the year of the entry. MM is the 2-digit month of the entry. DD is the 2-digit day of the entry.
#FormatDate($entry $format) Print out the date for a blog entry using the specified format. The format pattern uses the pattern letters defined for Java's Simple Date Format.
#DaysSincePosted($entry) Prints out the number of days since the blog entry was posted. You must be using the Days Since Posted plugin.
#TrackbackAutoDiscovery($entry $runFriendlyPermalink) Output the trackback auto-discovery code for the entry passed to the macro. If $runFriendlyPermalink is set to true, the macro will generate the friendly permalink structure.
#TotalCommentsPendingModeration($entry) Creates a page variable $totalCommentsPendingModeration with the total # of comments pending moderation.
#TotalCommentsApproved($entry) Creates a page variable $totalCommentsApproved with the total # of comments approved.
#TotalTrackbacksPendingModeration($entry) Creates a page variable $totalTrackbacksPendingModeration with the total # of trackbacks pending moderation.
#TotalTrackbacksApproved($entry) Creates a page variable $totalTrackbacksApproved with the total # of trackbacks approved.
#XMLRPCLink($entry $xmlrpcurl) Creates a page variable $xmlrpcLink of the form $BLOJSOM_BLOG.getBlogBaseURL()/$xmlrpcurl/$BLOJSOM_USER/$categoryForEntry$entry.getDateAsFormat('yyyy')/$entry.getDateAsFormat('MM')/$entry.getDateAsFormat('dd')/$entry.getPermalink().

Category Macros

The following macros can be used to print out information about a blog category.

Macro Description Availability
#CategoryName($blogCategory) Print out the descriptive category name for a blog category. If the descriptive name is not available, the category name is used.
#SanitizedCategory($category) Creates a page variable $sanitizedCategory which contains the sanitized category name. Preceding and trailing slashes are trimmed. blojsom 2.25

Plugin Macros

The following macros encapsulate functionality of certain plugins.

Macro Required Plugin Description
#Obfuscate($text) Simple Obfuscation plugin Obfuscates the text passed to the macro according to the plugin.
#MathCommentQuestion() Math Comment Moderation plugin Prints out the math question for your comment form.
#MathCommentFormItem() Math Comment Moderation plugin Prints out a form item with the math question for your comment form along with the form input item mathAnswerCheck.
#RSSEnclosure($entry) RSS Enclosure plugin Prints out the RSS 2.0 enclosure item for the blog entry, if available.
#DisplayWeatherForecast($weatherInfo) Weather plugin Prints out location, temperature, visibility, and a link to get detailed weather information.

Template Snippet Macros

The following macros generate larger portions of a page.

Macro Description Availability
#Calendar() Generate the calendar showing entries for the current month and links to navigate to other months.
#CommentFormWithPreview($entry) Generate the comment form for a given entry with a <div></div> for the Live Preview JavaScript code.
#MonthlyArchive($startingMonth $startingYear) Creates a list of links to navigate entries in your blog using the URL syntax of BLOG_URL/YYYY/MM/. The overall list is enclosed between <ul></ul tags and each month is enclosed in <li></li> tags. Pass in the month and year you've started your blog.
#MultiBlogFriendlyPermalink($entry) Friendly permalink macro appropriate for use when aggregating entries using the Internal Aggregator Plugin. blojsom 2.24
#NavigationLinks($homeText) Print out previous entry and next entry links (using friendly permalinks). The value for $hometext will be used as text for the link to the main blog's URL.
#Resource($item) Generate a link to the current blog's resources for a given item. Resulting URL will be of the form http://your.site.com/(servlet-context)/resources/(blog-id)/$item.
#SearchBox() Output a search form. Form enclosed inside <div></div> tags with an id of searchbox. Search label has <p></p> with id of searchlabel. Search field has <p></p> with id of searchfield. Search image has <p></p> with id of searchimg.

Site running on a free Atlassian Confluence Open Source Project License granted to blojsom. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators