Navigation

Search

prepareSearchContext

Description

Callback function for the results sub template.

Syntax

array prepareSearchContext ([bool $reset])



Parameter $reset

Expected type: Boolean
Description: If true, returns back to the beginning of the result set from the query. Default is false.



Return value

Expected type: Array
Description: An array containing massive arrays of data for the search results (each array is a separate result)

Array Elements
Key Optional Expected type Description
board no Array Information about the board where this topic resides: id (board ID), name (name of the board), href (URL to the board), link (HTML link to the board)
can_mark_notify no Boolean Whether or not the searcher can request notification of replies to this topic
can_reply no Boolean Whether or not the searcher can reply to this topic
category no Array An array of information about the category...: id (category ID), name (category name), href (URL to category), link (HTML link to the category)
first_post no Array An array of information about the first post in this topic: id (message ID), icon (name of the message icon), icon_url ([1.1 only] URL to the message icon), time (when the post/topic was made), subject (topic subject), href (URL to topic), link (HTML link to topic), member (array of information about the person who started this topic - id [member ID or 0 if they're a guest], name [name of the poster], href [URL to poster's profile, if applicable], link [HTML link to user's profile; just the name if they're a guest])
icon_url no String (1.1 only) The url to the message icon
id no Integer The ID of the topic that this post was found in
is_hot no Boolean Whether or not this is a "hot" topic (number of replies greater than or equal to hotTopicPosts setting)
is_locked no Boolean Whether or not this topic is locked
is_poll no Boolean Whether or not this post has a poll in it (also depends on whether or not polls are enabled)
is_sticky no Boolean Whether or not the topic is a sticky topic
is_very_hot no Boolean Whether or not this topic is "very hot" (number of replies greater than or equal to hotTopicVeryPosts setting)
last_post no Array An array of information about the last post in this topic: id (message ID), icon ([1.1 only] the name of the message icon), icon_url ([1.1 only] URL to the message icon), time (formatted date/time string indicating when the post was made), timestamp (UNIX timestamp of date/time when post was made), member (array of information about the person who made the last post in this topic - id [ID of the member who made this post or 0 if they're a guest], name [name of the poster], href [URL to poster's profile, if applicable], link [HTML link to poster's profile, or just the name if they're a guest])
matches no Array An array of information about the specific matches from this topic: id (message ID), attachments (array of info about any attachments this post has), alternate (either 0 or 1 - used for alternating background colors), member (themeUser array of info about the poster), icon (message icon for this result), subject (subject of the post), subject_highlighted (subject with any matches highlighted), time (formatted time/date string of when the message was posted), timestamp (raw UNIX timestamp of when the message was posted), counter (incremental counter - mainly used to calculate alternate), modified (array of info about when the message was modified: time [formatted date/time of when the message was modified], timestamp [timestamp of when the message was modified], name [name of the person who modified it]), body (the message itself), body_highlighted (body with any matching search terms highlighted), start (msg . {message_id} string that SMF uses to determine what page to start on)
num_matches no Integer The number of matches from this post
posted_in no Boolean (1.1 only) True if participation icons are enabled and the user posted in this topic; false otherwise
relevance no String The relevance of this result (internally calculated, semi-complicated - see code for more info)
views no Integer The number of times this topic has been viewed
quick_mod yes Array (1.1 only) If quick moderation is enabled, an array indicating whether or not the user can perform each quick moderation action: lock, sticky, move or remove


Notes

  • Loads the necessary contextual data to show a search result.
  • The massive array contains all the information for displaying the result.
  • Not all of this is used, but this is all the information available should you wish to customize the search results page.
View all versions of this function