LinkDirectoryXSLTHelper


The class org.ametys.plugins.linkdirectory.LinkDirectoryXSLTHelper provides a number of methods accessible from XSLT files, facilitating the integration of directory link information.

  1. How to use these methods
  2. Reference
    1. getColors
    2. getDefaultColorIndex
    3. getLinks
    4. getLinksForCurrentUser

How to use these methods

Add the xmlns namespace to the header of the XSL file:

<xsl:stylesheet version="1.0" 
           xmlns:xsl="http://www.w3.org/1999/XSL/" 
           xmlns:link="org.ametys.plugins.linkdirectory.LinkDirectoryXSLTHelper"
         exclude-result-prefixes="link"/>          

Call any of the functions defined below, using link:functionName(argument1, argument2)

Reference

getColors

Description:
Gets all the colors available for links in the directory (for the current site or a given site).

Signatures :
MapElement getColors()

MapElement getColors(String siteName)

Arguments:

Name

Type

Description

siteName

String

The name of the site.
Use the no-argument method for the current site.

Example:

<colors>
   <1>
       <main>#FF66FF</main>
       <text>#FFFFFF</text>
   </1>
   <2>
       <main>#CC33CC</main>
       <text>#FFFFFF</text>
   </2>
   [...]
</colors>                         

getDefaultColorIndex

Description:
Returns the default color index (for the current site or a given site)

Signatures :
String getDefaultColorIndex()

String getDefaultColorIndex(String siteName)

Arguments:

Name

Type

Description

siteName

String

The name of the site.
Use the no-argument method for the current site.

 

The #getColors and #getDefaultColorIndex methods can be used, for example, to select a color from the list of possible colors when a user creates a personal link.

getLinks

From versions 2.19.1 and 2.20.0

Description :

Return links to the directory, without access restrictions, for a given theme.

Signature :

NodeList getLinks(String siteName, String lang, String themeName)

Arguments:

Name

Type

Description

siteName

String

site name

lang

String

the language

themeName

String

theme identifier (e.g. SOCIAL_NETWORK)

For example:

<xsl:variable name="links" select="link:getLinks($site, $lang, 'SOCIAL_NETWORKS'/>
<ul>
  <xsl:for-each select="$links/link">
    <li>
        <a href="{@url}">
          <xsl:attribute name="href">
              <xsl:choose>
                <xsl:when test="@urlType = 'PAGE'"><xsl:value-of select="resolver:resolve('page', @url)"/></xsl:when>
                <xsl:otherwise><xsl:value-of select="@url"/></xsl:otherwise>
              </xsl:choose>
          </xsl:attribute>
          <xsl:value-of select="@title"/>
        </a>
    </li>
  </xsl:for-each>
</ul>

getLinksForCurrentUser

From version 2.20.0

Description :

Returns directory links, accessible to the current user, for a given theme.
Only user access is checked. Users' personal links are not retrieved and no user preferences are taken into account when ordering or hiding links.

Please note that this method can only be used on limited-access, non-cacheable pages.

Signature :

NodeList getLinksForCurrentUser(String siteName, String lang, String themeName)

Arguments:

Name

Type

Description

siteName

String

site name

lang

String

the language

themeName

String

theme identifier (e.g. SOCIAL_NETWORK)

Example: see #getLinks

Back to top

Link directory