Simple:Press Documentation

Template Tag: Unanswered Posts

Description

sp_UnansweredPostsTag() – The Template Tag Unanswered Posts tag displays the most recent topics that only have 1 post in them which would make them unanswered or have no replies.

Usage

sp_UnansweredPostsTag($args=”);

Arguments

CAUTION:
Because a Simple:Press update may overwrite any of its supplied files causing any user modifications made within those files to be lost it is highly recommended if the value of any of this function’s arguments/parameters or the placement of this function in any file supplied by Simple:Press is to be changed, that the filename be noted, the exact differences be carefully documented, and all the information archived in a location where they are easily retrieved by the user.

  • In the event that a Simple:Press update overwrites the file containing the modifications, the modifications will have to be re-incorporated into the new file by the user.
  • The resulting modification and differences should again be carefully documented and archived.

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.

$args – List of arguments for controlling display.
Type:
(string) (optional)
Default:
‘tagId’ => ‘spUnansweredPostsTag’
‘tagClass’ => ‘spListTag’
‘listId’ => ‘spListItemTag%ID%’
‘listClass’ => ‘spListItemTag’
‘linkClass’ => ‘spLinkTag’
‘textClass’ => ‘spTextTag’
‘avatarClass’ => ‘spAvatarTag’
‘listTags’ => 1
‘forumIds’ => ”
‘limit’ => 5
‘itemOrder’ => ‘FTUD’
‘linkScope’ => ‘forum’
‘beforeForum’ => __(‘Forum: ‘, ‘sp-ttags’)
‘afterForum’ => ‘<br />’
‘beforeTopic’ => __(‘Topic: ‘, ‘sp-ttags’)
‘afterTopic’ => ‘<br />’
‘beforeUser’ => __(‘By: ‘, ‘sp-ttags’)
‘afterUser’ => ”
‘beforeDate’ => ‘& n b s p; -‘ (but no spaces between characters)
‘afterDate’ => ”
‘avatarSize’ => 25
‘niceDate’ => 1
‘postTip’ => 1
‘truncate’ => 0
‘echo’ => 1

tagId‘: A unique CSS id to use for div or list. This would be text.
tagClass‘: The CSS class to be applied for styling. This would be text.
listClass‘: The CSS class to be applied to list item style. This would be text.
linkClass‘: The CSS class to be applied to link style. This would be text.
textClass‘: The CSS class to be applied to text labels. This would be text.
avatarClass‘: The CSS class to be applied to avatar. This would be text.
listTags‘: Flag to indicate whether or not to wrap in <ul> and <li> tags. A one (1) is true and the tags are used. A zero (0) is false and a div will be used.
forumIds‘: A comma delimited list of forum id numbers. This is optional. The default is all forums.
limit‘: The number of topics to show in the list. This would be an integer number.
itemOrder‘: This parameter controls both which components are displayed and also the order in which they are displayed. This is entered as text and must be upper case (Capitals) without spaces or other characters.

    Use the following codes to construct this parameter.
    F – Displays the forum name
    T – Displays the Topic name
    A – Displays the users Avatar
    U – Displays the Users display name
    D – Displays the date of the post
    Note: The default ‘FTUD’ does not include the users Avatar.

linkScope‘: Controls what items are made into links (‘a’ tags): This is entered as text. NOTE that the Topic will ALWAYS be formed as a link. The following options are available:

  • forum – Display the Forum name as a link as well as the Topic.
  • all – Make the entire entry a link to the Topic.

beforeForum‘: The text to display before the forum title.
afterForum‘: The text to display after the forum title.
beforeTopic‘: The text to display before the topic title.
afterTopic‘: The text to display after the topic title.
beforeUser‘: The text to display before the user information.
afterUser‘: The text to display after the user information.
beforeDate‘: The text to display before the date.
afterDate‘: The text to display after the date.
avatarSize‘: The Pixel size of the avatar if it has been selected for display in the argument “itemOrder”. This is an integer number.
niceDate‘: Flag to indicate whether to display the date of the post in the “nicedate” format (‘X days/weeks/months ago’ where “X” is an integer number). Examples of the “nicedate” format are “1 week ago” and “5 days ago”. A one (1) is true and causes the post’s date to be displayed in “nicedate” format with the post. Zero (0) is false and causes the post’s date to not be displayed in the “nicedate” format with the post but as only the date. See sp_niceDate for the description of niceDate in the Codex.
postTip‘: Flag to indicate whether to display an excerpt of the post in a bubble when hovering the cursor over the topic title/link of a post in the list. This is similar to the results the argument ‘toolTip’ provides. A one (1) is true and an excerpt of the post is displayed when the cursor is hovered over the listed post’s title/link. A zero (0) is false and no post excerpt is shown when the cursor is hovered over the listed post’s title/link.
truncate‘: The number of characters at which to truncate both the forum title and topic title displayed in their respective headers. This is an integer number. A zero (0) results in no truncation.
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.

Special Notes

This template tag is included in the Template Tags and Widgets plugin available on the Simple:Press Our Plugin Library page.

The Using Plugins page describes how you obtain and install the Template Tags and Widgets plugin.

This is also the template tag file used by the Unanswered Topics Plugin in its ‘spUnansweredView.php’ file.

Examples

An example of using this tag with only default settings.

sp_UnansweredPostsTag();

An example of using this tag with the item order set, the limit set to 10, and the HTML <hr /> after the date.

sp_UnansweredPostsTag('itemOrder=FTAUD&&limit=10&afterDate=<hr/>');

This function can also be called by using a shortcode on pages, posts or widgets.

[sp_unanswered_posts]

Actions and Hooks Used in Template Tag

  • apply_filters(‘sph_UnansweredPostsTag_args’, $a) – Allows modification of the arguments to the template tag. $a contains the parsed arguments.
  • apply_filters(‘sph_UnansweredPostsTag’, $out) – 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.1.

Codex page sync’d to code version 6.0.1.

Source Code

sp_UnansweredPostsTag() is located in …sp-resources/forum-plugins/template-tags/library/sp-UnansweredPosts-tag.php.

More Topics In SimplePress: Plugins


Copyright © 2006-2019 Simple:Press. All Rights Reserved.