sp_TopicIndexLastPost

Important Note:  The contents of this document applies ONLY to version 5.x.x of Simple:Press.  It likely does NOT apply to version 6.x.x (our latest version).

Description

sp_TopicIndexLastPost() – Displays summary information for the last post made to a topic in a forum and provides an ‘in row’ icon link to the last post.

Usage

sp_TopicIndexLastPost($args=”, $label=”);

Arguments

Note: If the value of any of this function’s arguments/parameters or the placement of this function in standard supplied Simple:Press theme pages is to be changed, it is highly recommended that a Child Theme or a Custom Theme be developed to accept the changes.

See example 2, below, for a top level discussion of the process.

$args – List of arguments for controlling display.
Type:
(string) (optional)
Default:
‘tagId’ => ‘spTopicIndexLastPost%ID%’
‘tagClass’ => ‘spInRowPostLink’
‘labelClass’ => ‘spInRowLabel’
‘infoClass’ => ‘spInRowInfo’
‘linkClass’ => ‘spInRowLastPostLink’
‘iconClass’    => ‘spIcon’
‘icon’   => ‘sp_ArrowRight.png’
‘labelLink’ => 0
‘tip’ => 1
‘nicedate’ => 1
‘date’: => 0
‘time’ => 0
‘user’ => 1
‘stackuser’ => 1
‘stackdate’ => 0
‘truncateUser’ => 0
‘itemBreak’ => ‘<br />’
‘beforeUser’ => ‘& n b s p’
‘beforeDate’ => ”
‘echo’ => 1
‘get’ => 0

tagId‘: CSS ID to apply to the Div. %ID% is the forum ID number.
tagClass‘: CSS class to apply to the Div.
labelClass‘: CSS class added to the label (text) shown.
infoClass‘: CSS class added to the info (text) shown.
linkClass‘: CSS class added to the link(s) shown.
iconClass‘: CSS class for the icon image displayed.
icon‘: Filename of the file containing the icon displayed.
labelLink‘: Flag to determine whether the label displayed should also link to the last post in the same way that the icon does. A one (1) is true and the label displayed will also link to the post. A zero (0) is false and the label displayed will not link to the post. NOTE: In the example below “Last Post” is the label.
tip‘: Flag to indicate whether or not to display a popup tooltip showing an excerpt of last post when the cursor is hovered over the post “link” icon (or over the label if ‘labelLink’ is set to a 1 (one)). A 1 (one) will display the excerpt when hovering the icon (or over the label if ‘labelLink’ is set to a 1 (one)). A 0 (zero) will not display the excerpt when hovering the icon (or over the label if ‘labelLink’ is set to a 1 (one)).
nicedate‘: Flag to indicate whether or not to show the time since the last post in ‘nicedate’ format (‘X days/weeks/months ago’ where “X” is an integer number). A 1 (one) will display in the ‘nicedate’ format. A zero (0) will not display in the ‘nicedate’ format. NOTE: If this is set to a 1 (one), then ‘date’ should be set to 0 (zero). This argument takes priority over the ‘date’ and ‘time’ arguments.
date‘: Flag to indicate whether or not to show the actual date of the last post instead of the time since the last post. A 1 (one) will display the actual date if ‘nicedate’ is set to 0 (zero). A 0 (zero) will not display the actual date of the post. NOTE: The ‘nicedate’ argument takes priority over this argument.
time‘: Flag to indicate whether or not to show the actual time of day of the last post. A 1 (one) will display the actual time of the last post only if the ‘date’ argument is set to a 1 (one) and the ‘nicedate’ argument is set to a 0 (zero). A 0 (zero) will not display the actual time of the first post.
user‘: Flag to indicate whether or not to display the last post’s author’s name. A 1 (one) will display the author’s name. A 0 (zero) will not display the author’s name.
stackuser‘: Flag to indicate what character(s) to insert before the last post’s author’s name. A 1 (one) will insert a linefeed (<br>). A 0 (zero) will insert the characters specified by the ‘beforeUser’ argument.
stackdate‘: Flag to indicate whether to stack the actual date of the last post on top of the actual post time as opposed to side by side. A 1 (one) will stack them if ‘date’ is set to a 1 (one) and ‘nicedate’ is set to a 0 (zero). A 0 (zero) will separate the date and time with a hyphen (-) if ‘date’ is set to a 1 (one) and ‘nicedate’ is set to a 0 (zero).
truncateUser‘: Integer indicating the number of characters in the last post’s author’s name to display (where to truncate). A 0 (zero) indicates the author’s name will not be truncated. EXAMPLE: Setting ‘truncateUser’ to 11 will display 11 characters in the author’s name.
itemBreak‘: Character(s) to output after the last post’s author’s name is displayed. The default (<br>) causes a linefeed.
beforeUser‘: Character(s) to be inserted before the last post’s author’s name is displayed only if ‘stackuser’ is set to 0 (zero).
beforeDate‘: Character(s) to be inserted before the date of the last post is displayed if ‘date’ or ‘nicedate’ is set to a 1 (one).
echo‘: Flag to indicate whether to write out the generated html display code or just return the html display code. One (1) is true and causes the html display code to be written to the display. Zero (0) is false and causes the html display code to be returned instead of written out.
get‘: Flag to indicate whether to short circuit the template tag display process and simply return data or to proceed with normal HTML display code generation. One (1) is true and the template tag display process is not done and data is returned. Zero (0) is false and normal html display code generation happens.

$label – Text (label) to display before the last post information.
Type:
(string) (optional)
Default:
None

Special Notes

In standard supplied Simple:Press themes this function is provided in the Forum View which for most themes is specified by the ‘spForumView.php’ file.

  • The exception is the Reboot theme where the function is in the ‘spForumViewDesktop.php’ and ‘spForumViewMobile.php’ files.

Examples

1). Display last post information using default options, aligned right with time since last post displayed in “nicedate” format and with the text “Last Post” shown before the poster’s name. NOTE: This is the call in several of the standard supplied themes.

sp_TopicIndexLastPost('iconClass=spIcon spRight&nicedate=1&date=0&time=0&stackdate=0', __sp('Last Post'));

If the call would modify a standard supplied Simple:Press theme’s file, it is highly recommended that a child theme be developed to accept the change. See example 2 for a brief discussion keeping in mind to substitute the name of the desired parent theme and file for those in the example.

2). Using the child theme based on the “Default” theme, in the Forum View display the last post information using defaults but aligned right with ‘iconClass’ of “spIcon spRight”, the label linked to the last post, the author’s name truncated at 11 characters, the actual post date and post time shown but not in the stacked format, and the label of “Last Post”.

A. If not already done, download the Default Child Framework and set it up as discussed in the Creating a Child Theme page. If not already done, copy the Default theme’s ‘spForumView.php’ file over to the child theme folder. Modify its “sp_TopicIndexLastPost()’ call as shown below and save.

sp_TopicIndexLastPost('iconClass=spIcon spRight&labelLink=1&truncateUser=11&nicedate=0&date=1&time=1&stackdate=0', __sp('Last Post'));

Actions and Hooks Used in Template Tag

  • apply_filters(‘sph_TopicIndexLastPost_args’, $a) – Allows modification of the arguments to the template tag. $a contains the parsed arguments.
  • apply_filters(‘sph_TopicIndexLastPost’, $out, $a)– Allows modification of the display code just prior to being output/returned. $out will contain the html display code.

Changelog

Since Simple:Press version 5.0.
Version: 5.1.0 – ‘ItemBreak’ argument added.
Version: 5.5.2 – ‘labelLink’ argument added.
Version 5.5.9 – ‘beforeUser’ and ‘beforeDate’ arguments added.

Codex page sync’d to code version 5.5.9.

Source Code

sp_TopicIndexLastPost() is located in simple-press/forum/content/sp-forum-view-functions.php.

Related

TopicIndexFirstPost

Posted in