Extension:Title Icon

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.svg
Title Icon

Release status:Extension status stable

ImplementationTemplate:Extension#type User interface
DescriptionTemplate:Extension#description Displays an icon to the left of the page title at the top of the page and in search results. Often used to help users easily recognize pages in a particular category.
Author(s)Template:Extension#username Cindy Cicalese (cindy.cicalesetalk)
Latest versionTemplate:Extension#version 4.0 (2017-09-28)
Compatibility policyCompatibility#mediawiki_extensions master
MediaWikiTemplate:Extension#mediawiki 1.28+
PHPTemplate:Extension#php 5.3+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license MIT License
Download
ParametersTemplate:Extension#parameters
  • $wgTitleIcon_EnableIconInPageTitle
  • $wgTitleIcon_EnableIconInSearchTitle
  • $wgTitleIcon_CSSSelector
  • $wgTitleIcon_UseFileNameAsToolTip
  • $wgTitleIcon_TitleIconPropertyName
  • $wgTitleIcon_HideTitleIconPropertyName
Hooks usedTemplate:Extension#hook
BeforePageDisplayManual:Hooks/BeforePageDisplay
ShowSearchHitTitleManual:Hooks/ShowSearchHitTitle
ParserFirstCallInitManual:Hooks/ParserFirstCallInit

Translate the Title Icon extension if it is available at translatewiki.net

Check usage and version matrix.

IssuesPhabricator

Open tasks · Report a bug

The Title Icon extension places an icon beside the page title when the title is displayed at the top of the page and when the page is listed in search results. Display of such an icon can help users easily visually detect that a page is in a particular category. This helps on the page itself, but also helps when trying to pick out the correct page from a list of search results.

The icon is specified by a semantic property of type Text that indicates the filename of an image file uploaded to the wiki. The extension looks for the property on the page itself and on the category page of any category to which the page belongs. Multiple icons will be displayed where multiple values are assigned to the property up to a maximum of five for each page queried for the property (the page itself and its categories). However, if the same icon is specified more than once, it will only be displayed once. The icon is sized to 36 pixels by 36 pixels maintaining its original aspect ratio.

By default, Title Icon will insert the icon in the title at the top of a page for any skin that puts the title in an HTML element with id firstHeading such as the default Vector skin. This can be changed for other skins using the $wgTitleIcon_CSSSelector configuration variable. This approach can also be used to have the Title Icon appear at other places in the page by using a <div> and appropriate choice of $wgTitleIcon_CSSSelector.

Special thanks to Bernadette Clemente for the original idea that inspired this extension and to Keven Ring for an early implementation of this extension.

Installation[edit]

Note Note: This extension requires Semantic MediaWiki to be installed first.

  • Download and place the file(s) in a directory called TitleIcon in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'TitleIcon' );
    
  • Configure as required.
  • YesY Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration parameters[edit]

Flag Default Description
$wgTitleIcon_EnableIconInPageTitle true Enables/disables the addition icons to the title bar of pages for this wiki.
$wgTitleIcon_EnableIconInSearchTitle true Enables/disables the addition icons to the title of pages listed in search results for this wiki.
$wgTitleIcon_CSSSelector "#firstHeading" Specifies the CSS selector that will be used to locate the page title. The Vector skin uses #firstHeading. The Foreground skin uses h2.title if it's the Foreground skin before December 2015. If it's after that date the CSSSelector is the same as the Vector skin.
$wgTitleIcon_UseFileNameAsToolTip true When set to true, uses the name of the image file with the file extension (the first "." and anything following it) removed as the tooltip when the mouse hovers over the icon. When set to false, the title of the page where the icon was set in the title icon property (either the page itself or one of its category pages) will be used instead.
$wgTitleIcon_TitleIconPropertyName "Title Icon" The name of the property of type Text that is used to specify the title icon image file name. NOTE: This property must exist, and it must be of type Text.
$wgTitleIcon_HideTitleIconPropertyName "Hide Title Icon" The name of a property of type Text that can be used to control the display of title icons for a given page.

If this property is set to "category" on a page, no title icons specified in the title icon property of any categories to which this page belongs will be shown on the title bar of this page or when this page is listed in search results.
If this property is set to "page", no title icons specified in the title icon property on this page will be shown on the title bar of this page or when this page is listed in search results.
If this property is set to "all", no title icons will be shown on the title bar of this page or when this page is listed in search results.
If this property is not set or is set to any value other than those above, title icons specified in the title icon property on this page and of any categories to which this page belongs will be shown on the title bar of this page or when this page is listed in search results.

NOTE: The $TitleIcon_UseDisplayTitle and $TitleIcon_DisplayTitlePropertyName parameters were removed in version 2.0 since they duplicate and conflict with functionality provided by the Semantic Title extension.

Release Notes[edit]

Version 4.0
  • Fixes rendering in search results which breaks compatbility with MediaWiki 1.27 and lower
Version 3.0
  • Removed use of inline JavaScript that caused issues in MediaWiki 1.26
  • Converted to new extension registration style
  • Removed support for old style i18n and extension registration
  • Renamed configuration variables with $wg prefix to support new extension registration format
Version 2.2
  • Added $TitleIcon_CSSSelector and updated coding style

Examples[edit]

Category:Title Icon Example:


{{#set:Title Icon=Event.png}}
{{#set:Title Icon=FAQ.png}}

Title Icon Example 1:


{{#set:Title Icon=Report.png}}
{{#set:Title Icon=FAQ.png}}
[[Category:Title Icon Example]]

Title Icon Example 2:


{{#set:Hide Title Icon=all}}
{{#set:Title Icon=Report.png}}
{{#set:Title Icon=FAQ.png}}
[[Category:Title Icon Example]]

Title Icon Example 3:


{{#set:Hide Title Icon=page}}
{{#set:Title Icon=Report.png}}
{{#set:Title Icon=FAQ.png}}
[[Category:Title Icon Example]]

Title Icon Example 4:


{{#set:Hide Title Icon=category}}
{{#set:Title Icon=Report.png}}
{{#set:Title Icon=FAQ.png}}
[[Category:Title Icon Example]]

Title Icon Example 5:


{{#set:Title Icon=Event.png}}
{{#set:Display Title=Events}}

Display of examples for the Title Icon extension