Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

Manual:SkinMustache.php

From mediawiki.org
Translate this page
Languages:
MediaWiki file: SkinMustache.php
Location:includes/skins/
Source code:master1.44.01.43.31.39.13
Classes:SkinMustache

The SkinMustache class is a generic class for use withMustache templates. It allows skin developers the flexibility to display the underlying data however they chose.A Mustache template is associated with the skin to be rendered and receives template data as described below.

To explore this more seeManual:How to make a MediaWiki skin.

Template data

[edit]

All data referenced here can be explored using theSkinJSON skin.

The Mustache skin associated with a skin receives the following data:

Template keyData typeUsageAvailable in MediaWiki version
array-sectionsSection[]Allows skins to render table of contents separately from the article body.1.38
data-logosDataLogosProvides access to information about logos as described in$wgLogos1.36
array-indicatorsDataHtmlObject[]An array of raw HTML items. Can be used to displayHelp:Page status indicators1.35
data-search-boxDataSearchBoxUsed to render the search (see below)1.35
html-site-noticestring (HTML)Render via triple braces to support the display of banners.

Including this adds support forsite notices.

1.35
html-user-messagestring (HTML)Can be used to display the yellow message bar notifying the user they have talk page messages inside the article body.

Example of the user message:File:010405ah.png

1.35
html-titlestring (HTML)Must be rendered to display the page title. Note that wikipage titles may contain certain HTML elements for example the‎<i> tag for italized text. The HTML does not include the heading tag, as it's up to you which tag to use e.g. h1 or h2.

If your skin is to be designed to support multiple languages you should also output {{{html-user-language-attributes}}}

1.35
html-subtitlestring (HTML)Can be rendered to display subtitles under the pagehtml-title. By default this is an empty string, but on certain pages - for example user subpages, and with certain MediaWiki extensions it will appear. Read more aboutsubtitles. The subtitle should be considered a block element, which may have several rows.1.35
html-body-contentstring (HTML)Must be rendered to display the content of the page1.35
html-categoriesstring (HTML)Can be rendered to display categories1.35
html-after-contentstring (HTML)Usually empty, but can be used to allow extensions such asRelatedArticles to render underneath an article (for example adverts). Include this HTML in a place that makes senseafter the main content.1.35
html-undelete-linkstring (HTML)Must be rendered if you want your skin to support a box on pages that have been deleted allowing them to be undeleted.1.35
html-user-language-attributesstring (HTML)HTML attributes that reflect the user's preferred language and its direction. Must be used on an element if you support RTL languages. Any child of the element will inherit these properties.Read more about language codes in the HTML spec.

As a general rule of thumb, you should only need to put this in root node(s) inside your skin.mustache file.

1.35
link-mainpagestringthe URL of the main page. Can be used to link back to the home page1.36
data-portletsDataPortletsObjectCan be used to render menus that extensions can extend and site admins can configure. Each menu must be accessed by name.

See below and the rendering menus section ofManual:How to make a MediaWiki skin.

1.36
data-portlets-sidebarDataPortletSidebarCan be used to render menus that traditionally appear in the sidebar of Vector that extensions can extend and site admins can configure. Data is separated into the first portlet and then an array of other portlets that must follow.

The content of this menu is treated separately from data-portlets as this menu can be configured inside the wiki via an edit to theSidebar. SeeManual:Interface/Sidebar for more information. The sidebar may contain a variable amount of submenus so is structured differently from data-portlets.

1.36
data-footerDataFooterCan be used to render footer links that extensions can extend and site admins can configure. Usually this contains links such as the "mobile view", disclaimers and privacy policy but can be configured by LocalSettings.php and extension.Read more about customization of the footer.1.36
msg-<message-key>stringA skin can declare messages at skin registration. Any message declared will be translated and passed to the template escaped. HTML messages are currently not supported.

Messages can be defined locally to the skin inside i18n/en.json oryou can use any of the messages defined in core. Learn more aboutLocalisation.

1.36
is-anonbooleantrue on pages where the user is not logged in1.38
is-articlebooleantrue on pages where the page being read is "an article" (e.g. main namespace)1.38
is-specialpagebooleantrue on pages where the page being read is a special page e.g. Special:Preferences1.38
is-mainpagebooleantrue if the page is the main page.1.38

Menus (akaportlets/portals)

[edit]

For backward compatibility there are several types of Menus to be aware of when rendering in SkinMustache.It is hoped in future a standardized menu format will be used for all.

Section

[edit]
Template keyData typeUsageAvailable in MediaWiki version
toclevelnumberIs this an h1, h2, h3?1.38
linestringThe heading of the section.1.38
levelstring1.38
numberstring1.38
indexstring1.38
from_titlestringThe page associated. Perhaps redundant.1.38
byteoffsetintegerThe byte offset where the section occurs.1.38
anchorstringThe anchor link1.38
has-subsectionsbooleanDoes this section have subsections?1.38
is-last-itembooleanIs this section the last of the current toclevel1.38

AttributeData

[edit]
Template keyData typeUsageAvailable in MediaWiki version
keystringThe name of an HTML attribute e.g. "href"1.40
valuestringThe value of a HTML attribute e.g. "/wiki/Link"1.40

PortletLinkData

[edit]
Template keyData typeUsageAvailable in MediaWiki version
iconstringIcon name1.40
array-attributesAttributeData[]Array of all the HTML attributes that can be rendered on a link.1.40
textstringText of the link1.40

PortletListItemData

[edit]
Template keyData typeUsageAvailable in MediaWiki version
html-itemstringHTML representation of list item and link1.40
namestringID unique to this specific menu (not typically rendered but can be useful for instrumentation purposes)1.40
idstringID of the menu item, typically rendered as ID attribute on list item (li)1.40
classstringclass attribute of the menu item, typically rendered as ID attribute on list item (li)1.40
htmlstringHTML of just the link (see also array-links)1.40
array-linksPortletLinkDataData structure representing the link(s) contained in the menu item.1.40

PortletData

[edit]

Menus (aka portlets/portals) in SkinMustache have a consistent data structure that looks like follows:

Template keyData typeUsageAvailable in MediaWiki version
idstringThe HTML ID attribute of the portlet. Must be output for compatibility with gadgets and extensions on a container element.1.36
classstringThe HTML class attribute of the portlet. Must be output for compatibility with gadgets and extensions on a container element.1.36
labelstringThe human readable name of the menu. Can be used for rendering a header for the menu. Generally, it is important to display this to all users when rendering groups of menus (e.g. sidebar, DataPortletSidebar) but not for single menus (DataPortletsObject).

We recommend you consider always rendering this in the page, as this label is important to screen readers and making your skin accessible.

1.36
html-tooltipstring (HTML)Other HTML Attributes that should be output along the ID and class. This may contain access key and title attributes.1.36
array-itemsPortletListItemDataEquivalent of html-items for skin developers who need more flexibility.1.40 (9c4f70c22251)
html-itemsstring (HTML)The list items representing the menu. Note when rendering this you must wrap it inside a list tag e.g. ol or ul1.36
html-after-portalstring (HTML)Extensions such asUniversalLanguageSelector have expressed a desire to add HTML at the end of a menu. Rendering is optional.

Note, despite the name skin developers may decide to render this in the same place as html-before-portlet.

Note this is not the same as html-before-portlet. You must render both for full extension compatibility.

1.36
html-before-portalstring (HTML)Can be rendered to allow extensions to add HTML before a menu. Rendering is optional.

Note this is not the same as html-after-portlet. You must render both for full extension compatibility.

1.37

DataPortletSidebar

[edit]
Template keyData typeUsageAvailable in MediaWiki version
data-portlets-firstPortletDataMust be used if your skin supports languages1.36
array-portlets-restPortletData[]Can be used to allow extensions to surface settings controls outside the context of Special:Preferences.1.36

DataPortletsObject

[edit]

The data-portlets object allows access to all the different menus that are available to render.Menus are organized into different buckets.A skin developer can choose to render each of these separately, to modify these buckets via theSkinTemplateNavigation::Universal hook, or omit them.Each menu contains data consistent with data-portlets-sidebar.

Template keyData typeUsageAvailable in MediaWiki version
data-languagesPortletDataMust be used if your skin supports languages1.36
data-user-interface-preferencesPortletDataCan be used to allow extensions to surface settings controls outside the context of Special:Preferences.1.37
data-user-pagePortletDataShould be used to render a link to the user's user page and user talk page.1.37
data-user-menuPortletDataShould be used to render links personal to a user e.g. their user contributions page and sandbox.1.37
data-notificationsPortletDataShould be used to render user notifications e.g. supportEcho1.37
data-namespacesPortletDataMust be used to provide access to the discussion page.1.36
data-viewsPortletDataMust be used to provide access to the edit and history links1.36
data-actionsPortletDataMust be used to provide access to admins to protect, delete and move actions.1.36
data-variantsPortletDataMust be used if your skin supports language variants1.36
data-personalPortletDataShould not be used if data-notifications, data-user-menu, data-user-page or data-user-interface-preferences are being used. In 1.37 this menu bucket was split up into multiple buckets. Usage is discouraged in new skins.1.36

DataFooterLine

[edit]
Template keyData typeUsageAvailable in MediaWiki version
idstringHTML ID attribute of item1.36
classNamestringCSS classes for that item that can be used. Note this property name is inconsistent with others. It may be renamed to class in future.1.36
array-itemsDataFooterItem (1.36)|PortletListItemData (1.40)Array of footer items to render1.36

DataFooterItem

[edit]
Template keyData typeUsageAvailable in MediaWiki version
namestringA unique name/key you can use to identify the footer line from others.1.36
idstringThe HTML ID attribute of the footer element, derived from name1.36
htmlstring (HTML)The raw HTML (usually a link)1.36

DataFooter

[edit]
Template keyData typeUsageAvailable in MediaWiki version
data-infoDataFooterLineContains last modified information.1.36
data-placesDataFooterLineUsed to render privacy, disclaimer. Used byMobileFrontend to add mobile view link.1.36
data-iconsDataFooterLineUsed to render icon images1.36

Other

[edit]

DataHtmlObject

[edit]

When dealing with this type, you are expected to create a container with id and class as attributes and html as its inner HTML. The container may contain other elements if you wish.The primary reason for the existence of this type, is you may want to render certain items as lists (`li` element) or blocks (`div` elements).

Template keyData typeUsageAvailable in MediaWiki version
idstringAn ID of container element1.35
classstringclasses for container element1.35
htmlstringraw HTML of component1.35

DataSearchBox

[edit]
Template keyData typeUsageAvailable in MediaWiki version
form-actionstringWhere the form should post to e.g. /w/index.php1.35
html-button-search-fallbackstring (HTML)A button that triggers a full text search. Usually, e.g. in Vector skin, this is hidden for users with JavaScript, but is important to include when considering the primary action of the form (e.g. what happens when the user hits ENTER key). In the MonoBook skin for example, two buttons are rendered to the user.

Consider placing this element after html-button-search and using `.client-js .mw-fallbackSearchButton` selector to hide this element.

Rendering this is optional, if you render html-button-search and at the discretion of the skin developer. See alsohtml-button-fulltext-attributes.

1.35
html-button-searchstring (HTML)A button that goes to a page with this exact name if it exists. If this is made the primary action of the form you should consider linking to the Special:Search page.

Rendering this is optional, if you render html-button-search-fallback and at the discretion of the skin developer. See alsohtml-button-go-attributes.

1.35
html-inputstring (HTML)search input element with placeholder text1.35
page-titlestring (HTML)This is a input[type=hidden] providing the localized title for search e.g. Special:Search. You must render it for your form to work without JavaScript as otherwise the search form will not know where to submit to.

Note, you should not hardcode this HTML as some extensions may change the default search page, for example,Extension:MediaSearch.

1.35
html-input-attributesstring (HTML)Helper template data that can be used instead of `html-input` to render a search input that is compatible with installed extensions and MediaWiki code.1.38
html-button-go-attributesstring (HTML)Helper template data that can be used instead of `html-button-search` to render a button or input[type=submit] element that is compatible with installed extensions and MediaWiki code.1.38
html-button-fulltext-attributesstring (HTML)Helper template data that can be used instead of `html-button-search-fallback` to render a button or input[type=submit] element that is compatible with installed extensions and MediaWiki code.1.38

DataLogos

[edit]

Note this data structure can be extended by extensions, and site configuration in LocalSettings.php

Template keyData typeUsageAvailable in MediaWiki version
iconstringPath to a square icon1.35
1xstringPath to a square icon at 1x resolution1.35
2xstringPath to a square icon at 2x resolution1.35
wordmarkLogoObjectFor a text logo e.g. Wikipedia1.35
taglineLogoObjectTagline for a site e.g. "The free encyclopedia".

Not to be confused with {{msg-tagline}} which renders the message called "tagline", however this can be used as a good fallback for when a tagline is not defined

e.g.

{{#data-logos}} {{! access logo data }}{{#tagline}} {{! tagline is defined! }}<imgsrc="{{src}}">{{/tagline}}{{^tagline}} {{! tagline is not defined! }}{{msg-tagline}} {{! render a message in its place }}{{/tagline}}
1.35

LogoObject

[edit]

Note this data structure can be extended by extensions, and site configuration in LocalSettings.php

Template keyData typeUsageAvailable in MediaWiki version
srcstringURL to the logo component1.35
widthnumberWidth in pixels1.35
heightnumberHeight in pixels1.35
stylestringThe value of a style attribute which expresses the height and width inem's based on a default browser font size of 16px. Can be used to make logos scale with changes to browser text size.1.38
Retrieved from "https://www.mediawiki.org/w/index.php?title=Manual:SkinMustache.php&oldid=7488231"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp