Help:Embedded format

From semantic-mediawiki.org
Help:Embedded formatEmbedded format/zh-hans
Embedded format
Embeds selected articles.
Further Information
Provided by: Semantic MediaWiki
Added: 0.7
Removed: still supported
Requirements: none
Format name: embedded
Enabled? Indicates whether the result format is enabled by default upon installation of the respective extension. yes
Authors: Markus Krötzsch
Categories: misc
Table of Contents

The result format embedded is used to embed the contents of the pages in a query result into a page. The embedding uses MediaWiki transclusion (like when inserting a template), so the tags <includeonly> and <noinclude> work for controlling what is displayed.

Parameters[edit]

General[edit]

Parameter Type Default Description
source text empty Alternative query source
limit whole number 50 The maximum number of results to return
offset whole number 0 The offset of the first result
link text all Show values as links
sort list of texts empty Property to sort the query by
order list of texts empty Order of the query sort
headers text show Display the headers/property names
mainlabel text no The label to give to the main page name
intro text empty The text to display before the query results, if there are any
outro text empty The text to display after the query results, if there are any
searchlabel text ... further results Text for continuing the search
default text empty The text to display if there are no query results

Format specific[edit]

Parameter Type Default Description
embedformat text h1 The HTML tag used to define headings
embedonly yes/no no Display no headings

The embedded format introduces the following additional parameters:

  • embedformat: this defines which kinds of headings to use when pages are embedded, may be a heading level, i.e. one of h1, h2, h3, h4, h5, h6, or a description of a list format, i.e. one of ul and ol
  • embedonly: if this parameter has any value (e.g. yes), then no headings are used for the embedded pages at all.

Example[edit]

The following creates a list of recent news posted on this site (like in a blog):

Syntax
{{#ask:
 [[News date::+]]
 [[Language code::en]]
 [[Is duplicate page::true]]
 |sort=news date
 |order=descending
 |format=embedded
 |embedformat=h2
 |embedonly=yes
 |searchlabel= <br>[view older news]
 |limit=3
}}
NoteNote: The newline (<br>) is used to put the further results link on a separate line.


Result

MediaWiki Users and Developers Conference 2024

The first MediaWiki Users and Developers Conference 2024 will occur on April 17 - 19, 2024 in Portland, Oregon, USA. Semantic MediaWiki-related talks are welcome.

Semantic MediaWiki at the MediaWiki Hackathon 2024

The MediaWiki Hackathon 2024 will occur on May 3 - 5, 2024 in Tallinn, Estonia. We will organize Semantic MediaWiki-related activities. You are welcome to propose an online or on-site activity. See hackathon page for more information and inscription.

SMWCon Fall 2023 will be held in Germany

Save the date! SMWCon Fall 2023 will take place December 11 - 13, 2023 in Paderborn, Germany. The conference is for everybody interested in wikis and open knowledge, especially in Semantic MediaWiki. You are welcome to propose a related talk, tutorial, workshop and more via the conference page.
[view older news]

Remarks[edit]

  • Note that by default this result format also adds all annotations from the pages that are being embedded to the page they are embedded to.1 Starting with Semantic MediaWiki 2.4.0Released on 9 July 2016 and compatible with MW 1.19.0 - 1.27.x. this can be prevented for annotations done via parser functions #set parser function and #subobject parser function by setting the embedonly parameter to "yes".2 in-text annotations will continue to be embedded. Thus these annotations need to be migrated to use the #set parser function to prevent this from happening.
  • Note that embedding pages may accidentally include category statements if the embedded articles have any categories. Use <noinclude> to prevent this, e.g. by writing <noinclude>[[Category:News feed]]</noinclude>. Starting with Semantic MediaWiki 3.0.0Released on 11 October 2018 and compatible with MW 1.27.0 - 1.31.x. category statements will automatically be filtered from transcluded content. Thus the described trick to prevent this from happening is no longer necessary.
  • Note that Semantic MediaWiki will take care that embedded articles do not import their semantic annotations, so these need not be treated specifically.
  • Note that printout statements have no effect on embedding queries.

Limitations[edit]

You cannot use the embed format to embed a query from another page if that query relies on the magic word {{PAGENAME}}.


References

  1. ^  Semantic MediaWiki: GitHub issue gh:smw:1076
  2. ^  Semantic MediaWiki: GitHub pull request gh:smw:1455