From version < 16.1 >
edited by slauriere
on 2019/06/06
To version < 17.2
edited by slauriere
on 2019/06/06
<
Change comment: There is no comment for this version

Summary

Details

ExtensionPoint.UIXDescriptionClass[0]
How this Extension Point is used
... ... @@ -2,12 +2,39 @@
2 2  
3 3  It was introduced in version 11.1RC1 with the identifier ##org.xwiki.platform.head## and was later changed to ##org.xwiki.platform.html.head## in 11.5.
4 4  
5 -The first screenshot below illustrates an example of metadata tags injected into the HTML ##head## using this extension point. The second one shows the code used by a User Interface Extension (UIX) to produce such content.
5 +The screenshot below illustrates an example of metadata tags injected into the HTML ##head## using this extension point. The second one shows the code used by a User Interface Extension (UIX) to produce such content.
6 6  
7 -(% style="border: 1px solid #ccc" %)(((
7 +(% style="border: 1px solid #ccc; margin-bottom: 1em;" %)(((
8 8  [[image:html-head-extension-example.jpg]]
9 9  )))
10 10  
11 -(% style="margin-top: 1em; border: 1px solid #ccc" %)(((
12 -[[image:html-head-extension-code-example.jpg]]
13 -)))
11 +Such custom metadata tags can be produced by the following code sample, copied from the [[OpenGraph application>>extensions:Extension.OpenGraph Application.WebHome]].
12 +
13 +{{code}}
14 +{{velocity}}
15 +{{html clean="false"}}
16 +#set ($serverUrl = $xcontext.URLFactory.getServerURL($xcontext.context))
17 +#set ($hasImages = false)
18 +#macro(addOpenGraphTagsForAttachedImages $pageReference)
19 + #set ($page = $xwiki.getDocument($pageReference))
20 + #foreach ($attachment in $page.attachmentList)
21 + #if ($attachment.isImage())
22 + #set ($hasImages = true)
23 + #set ($path= $page.getAttachmentURL($attachment.filename))
24 + <meta property="og:image" content="$serverUrl$path" />
25 + #end
26 + #end
27 +#end
28 +<meta property="og:url" content="$doc.externalURL"/>
29 +<meta property="og:type" content="article" />
30 +<meta property="og:title" content="$tdoc.getRenderedTitle("plain/1.0")" />
31 +## Add all current page's image attachments as "og:image".
32 +#addOpenGraphTagsForAttachedImages($doc.documentReference)
33 +## If current page has no attached image, add the ones of the home page, if any.
34 +#set ($wikiDescriptor = $services.wiki.getById($xcontext.wiki))
35 +#if (!$hasImages && $wikiDescriptor && $doc.documentReference != $wikiDescriptor.mainPageReference)
36 + #addOpenGraphTagsForAttachedImages($wikiDescriptor.mainPageReference)
37 +#end
38 +{{/html}}
39 +{{/velocity}}
40 +{{/code}}

Adds content to the HTML "head" tag of all wiki pages

Usage

The extension point adds the provided content to the page HTML head element. It is typically useful for adding HTML metadata to pages. 

It was introduced in version 11.1RC1 with the identifier org.xwiki.platform.head and was later changed to org.xwiki.platform.html.head in 11.5.

The first screenshot below illustrates an example of metadata tags injected into the HTML head using this extension point. The second one shows the code used by a User Interface Extension (UIX) to produce such content.

The screenshot below illustrates an example of metadata tags injected into the HTML head using this extension point. The second one shows the code used by a User Interface Extension (UIX) to produce such content.

html-head-extension-example.jpg

html-head-extension-example.jpg

html-head-extension-code-example.jpg

Such custom metadata tags can be produced by the following code sample, copied from the OpenGraph application.

{{velocity}}
{{html clean="false"}}
#set ($serverUrl = $xcontext.URLFactory.getServerURL($xcontext.context))
#set ($hasImages = false)
#macro(addOpenGraphTagsForAttachedImages $pageReference)
  #set ($page = $xwiki.getDocument($pageReference))
  #foreach ($attachment in $page.attachmentList)
    #if ($attachment.isImage())
      #set ($hasImages = true)
      #set ($path= $page.getAttachmentURL($attachment.filename))
     <meta property="og:image" content="$serverUrl$path" />
    #end
  #end
#end
<meta property="og:url" content="$doc.externalURL"/>
<meta property="og:type" content="article" />
<meta property="og:title" content="$tdoc.getRenderedTitle("plain/1.0")" />
## Add all current page's image attachments as "og:image".
#addOpenGraphTagsForAttachedImages($doc.documentReference)
## If current page has no attached image, add the ones of the home page, if any.
#set ($wikiDescriptor = $services.wiki.getById($xcontext.wiki))
#if (!$hasImages && $wikiDescriptor && $doc.documentReference != $wikiDescriptor.mainPageReference)
  #addOpenGraphTagsForAttachedImages($wikiDescriptor.mainPageReference)
#end
{{/html}}
{{/velocity}}

Definition

This Extension Point is contributed by this extension and was added in version 11.1-rc-1 of that extension.

Category
HTML
Extension Id
org.xwiki.platform.html.head
Content to be provided

The content to be added in the HTML head tag of all wiki pages.

Parameters to be provided

Order: used for ordering the extensions.

Example

This extension point is used by the OpenGraph application.

Get Connected