global template - access to slot content

Hi

is there a way to access from a global template a value entered by the user into a related content item.

my global template looks for sys_window-title in the title tag. I have a content type that does not use this field - but an item that will be assembled into the content type does and i need to use that.

does anybody know how to do this.

thanks
michelle

Hi Michelle

I would be something like this:

<xsl:value-of select="document(//linkurl[@slotname='YOURSLOTNAME']/Value/@current)/*/title/text()" />

Cheers
James

thanks jimbo

How would we achieve this with velocity?

Thank you,

Bona.

hi

i have another question related to this please.

I am trying to use the solution below and this works fine if i want to select something that is actually displayed on the page. However, I need to access elements of the xml that are not displayed on the page and seem unable to do this.

Am i right in thinking that document() just gets the html of the displayed page? How do you access other xml elements of the related content page.

thanks
michelle

hi

can anyone help with this please - i am seriously struggling.

how do we access the xml using the document function, rather than the html?

thanks
michelle

Hi Michelle

All you have to do is replace the .html with .xml but as XSL doesn’t have a standard replace function here’s one to put into your rx_resources/stylesheets/assemblers/rxs_global.xsl file.

<xsl:template name="replace">
	<xsl:param name="string" select="''"/>
	<xsl:param name="pattern" select="''"/>
	<xsl:param name="replacement" select="''"/>
	<xsl:choose>
		<xsl:when test="$pattern != '' and $string != '' and contains($string, $pattern)">
			<xsl:value-of select="substring-before($string, $pattern)"/>
			<!--
			Use "xsl:copy-of" instead of "xsl:value-of" so that users
			may substitute nodes as well as strings for $replacement.
			-->
			<xsl:copy-of select="$replacement"/>
			<xsl:call-template name="replace">
				<xsl:with-param name="string" select="substring-after($string, $pattern)"/>
				<xsl:with-param name="pattern" select="$pattern"/>
				<xsl:with-param name="replacement" select="$replacement"/>
			</xsl:call-template>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="$string"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

Next load your .html document into a variable:

<xsl:variable name="document_link" select="/*/sys_AssemblerInfo/RelatedContent/linkurl[@slotname='YOURSLOTNAME']/Value/@current" />

Then use the replace function to replace html with xml:

<xsl:variable name="document_link_xml">
	<xsl:call-template name="replace">
		<xsl:with-param name="string" select="$document_link" />
		<xsl:with-param name="pattern">.html</xsl:with-param>
		<xsl:with-param name="replacement">.xml</xsl:with-param>
	</xsl:call-template>
</xsl:variable>

Now you can load any of the values of the backend xml into variable to use on your variant:

<xsl:variable name="document_link_xml_displaytitle" select="document($document_link_xml)/*/shared/displaytitle" />

Cheers
James

wow - thanks jimbo

i will give this a go now. strangely i was trying to do something similar but couldn’t quite get it to work.

thanks for your help
Michelle