CMS Ametys provides integrators with numerous methods accessible from XSLT files, facilitating the integration of user-related information.

For more information, click here.

  1. How to use these methods
  2. Reference
    1. getUserContent
    2. getCurrentUserContent
    3. getCurrentUserPage
    4. getUserPage
    5. getUserPage

How to use these methods

Add this code to the header of XSL files:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"                                   ...                                   xmlns:ametys="org.ametys.plugins.userdirectory.transformation.xslt.UserXSLTHelper"                                   ...                                   extension-element-prefixes="... ametys ...">                             

So that you can call any of the functions defined below, using "ametys:functionName(argument1, argument2)".

Reference

getUserContent

Description:
Returns the identifier of the "User" content linked to a user.
The language of the returned content will be:

  • the language passed in parameter if the content exists in this language
  • otherwise the "en" content if it exists
  • by default, the 1st existing user content from the list of languages supported by the application

Signature :
String getUserContent(String lang, String userIdentity)

Arguments:

Name

Type

Description

lang

String

Preferred language for content. Can be empty or null.

userIdentity

String

User identity in the form login#population

getCurrentUserContent

Description :

Returns the identifier of the "User" content linked to the current user.
The language of the returned content will be:

  • the language passed in parameter if the content exists in this language
  • otherwise the "en" content if it exists
  • by default, the 1st existing user content from the list of languages supported by the application

Signature :
String getCurrentUserContent(String lang)

Arguments:

Name

Type

Description

lang

String

Preferred language for content. Can be empty or null.

Example:

<xsl:variable name="userContentId" select="user:getCurrentUserContent(ametys:lang())"/> 
<p><strong>Fonction: </strong><xsl:value-of select="ametys:contentMetadata($userContentId, 'function')"/></p>                        

getCurrentUserPage

Description :
Returns the identifier of the directory page linked to the current user, in the current site.
Return to null if no page exists for the current user.

Signature :
String getCurrentUserPage(String lang)

Arguments:

Name

Type

Description

lang

String

Preferred language for content. Can be empty or null.

Example:

<xsl:variable name="currentUserPageId" select="user:getCurrentUserPage(ametys:lang())"/>
<xsl:if test="$currentUserPageId != ''">
  <a href="{resolver:resolve('page', $currentUserPageId, false)}">Voir mon profil</a>           
</xsl:if>

getUserPage

Description :
Returns the identifier of the directory page in the current site, linked to "User" content.
Return to null if no page exists for the user in the current site.

Signature :
String getUserPage(String contentId)

Arguments:

Name

Type

Description

contentId

String

User content identifier

Example:

<xsl:variable name="page-id" select="user:getUserPage(@id)"/>
<a href="{resolver:resolve('page', $page-id, false)}">
  <xsl:value-of select="metadata/title"/>           
</a>

getUserPage

Description :
Returns the identifier of the directory page linked to "User" content and a given site.
Return to null if no page exists for the user in the given site.

Signature :
String getUserPage(String contentId, String siteName)

Arguments:

Name

Type

Description

contentId

String

User content identifier

siteName

String

Site name

               

                       

Back to top

User directory