Hi guys,
Just have a quick question.
Looking at my architecture below....
Calling an XSLT function from the Portfolio page, I would like to loop through the portfolio child pages and grab some meta type values from those children, and display that information on the parent page (Portfolio). Is this possible? (I have been looking for literally hours to get this to work, but to no avail.)
Site Architecture
Name: PortfolioDetails
Namespace: Custom
Fields: Thumbnail (C1 image), ExternalLink (string), BannerImage (C1 image)
And I have added this to my page type, and filled in the details for the portfolio child pages. The code is below. I have actually modified code from the Composite package called Composite.Navigation.Distributed.XSLT because I had so much trouble getting my xslt to work.
The code in particular that I'm working with is in the mode="Page" template. The line in particular is <xsl:value-of select="/in:inputs/in:result[@name='GetPortfolioDetailsXml']/PortfolioDetails/@ExternalLink" />
Full code below:
Just have a quick question.
Looking at my architecture below....
Calling an XSLT function from the Portfolio page, I would like to loop through the portfolio child pages and grab some meta type values from those children, and display that information on the parent page (Portfolio). Is this possible? (I have been looking for literally hours to get this to work, but to no avail.)
Site Architecture
- Home
- About
-
Portfolio
- Item 1
- Item 2
-
Item 3
Name: PortfolioDetails
Namespace: Custom
Fields: Thumbnail (C1 image), ExternalLink (string), BannerImage (C1 image)
And I have added this to my page type, and filled in the details for the portfolio child pages. The code is below. I have actually modified code from the Composite package called Composite.Navigation.Distributed.XSLT because I had so much trouble getting my xslt to work.
The code in particular that I'm working with is in the mode="Page" template. The line in particular is <xsl:value-of select="/in:inputs/in:result[@name='GetPortfolioDetailsXml']/PortfolioDetails/@ExternalLink" />
Full code below:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl in" xmlns:in="http://www.composite.net/ns/transformation/input/1.0" xmlns:data="http://www.composite.net/ns/data" xmlns="http://www.w3.org/1999/xhtml">
<xsl:output indent="no" method="xml" />
<xsl:param name="parent" select="/in:inputs/in:param[@name='Parent']" />
<xsl:param name="childs" select="/in:inputs/in:param[@name='Childs']" />
<xsl:param name="expand" select="/in:inputs/in:param[@name='Expand']" />
<xsl:param name="level" select="/in:inputs/in:param[@name='Level']" />
<xsl:param name="startPage" select="/in:inputs/in:param[@name='StartPage']" />
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="~/Frontend/Composite/Navigation/Distributed/Styles.css" />
</head>
<body>
<div id="{/in:inputs/in:param[@name='NavigationId']}">
<xsl:choose>
<xsl:when test="$startPage = ''">
<xsl:apply-templates mode="Level" select="/in:inputs/in:result[@name='SitemapXml']">
<xsl:with-param name="level" select="$level" />
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates mode="Level" select="/in:inputs/in:result[@name='SitemapXml']//Page[@Id=$startPage]">
<xsl:with-param name="level" select="$level - 1" />
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</div>
</body>
</html>
</xsl:template>
<xsl:template mode="Level" match="*">
<xsl:param name="level" />
<xsl:if test="$level < 1">
<xsl:if test="count(./*) or $parent='true'">
<ul>
<xsl:if test="$parent='true'">
<xsl:apply-templates mode="Page" select=".">
<xsl:with-param name="showchilds" select="'false'" />
</xsl:apply-templates>
</xsl:if>
<xsl:apply-templates mode="Page" select="./*" />
</ul>
</xsl:if>
</xsl:if>
<xsl:if test="$level > 0">
<xsl:apply-templates mode="Level" select="./*[@isopen='true']">
<xsl:with-param name="level" select="$level - 1" />
</xsl:apply-templates>
</xsl:if>
</xsl:template>
<xsl:template mode="Page" match="*">
<xsl:param name="showchilds" select="$childs"></xsl:param>
<xsl:if test="@MenuTitle != ''">
<li>
<xsl:apply-templates mode="Class" select="." />
<a href="{@URL}">
<xsl:apply-templates mode="Class" select="." />
<xsl:value-of select="@MenuTitle" />
<xsl:value-of select="/in:inputs/in:result[@name='GetPortfolioDetailsXml']/PortfolioDetails/@ExternalLink" />
</a>
<xsl:if test="count(./*)>0 and $showchilds='true' and (@isopen='true' or $expand='true')">
<ul>
<xsl:apply-templates mode="Page" select="./*" />
</ul>
</xsl:if>
</li>
</xsl:if>
</xsl:template>
<xsl:template mode="Class" match="*">
<xsl:if test="@isopen='true'">
<xsl:attribute name="class">NavigationOpen</xsl:attribute>
</xsl:if>
<xsl:if test="@iscurrent='true'">
<xsl:attribute name="class">NavigationSelected</xsl:attribute>
</xsl:if>
</xsl:template>
SAMPLE XML:<in:inputs xmlns:in="http://www.composite.net/ns/transformation/input/1.0">
<!-- Input Parameter, XPath /in:inputs/in:param[@name='Level'] -->
<in:param name="Level">0</in:param>
<!-- Input Parameter, XPath /in:inputs/in:param[@name='Parent'] -->
<in:param name="Parent">true</in:param>
<!-- Input Parameter, XPath /in:inputs/in:param[@name='Childs'] -->
<in:param name="Childs">true</in:param>
<!-- Input Parameter, XPath /in:inputs/in:param[@name='Expand'] -->
<in:param name="Expand">false</in:param>
<!-- Input Parameter, XPath /in:inputs/in:param[@name='NavigationId'] -->
<in:param name="NavigationId">NavigationSideBar</in:param>
<!-- Input Parameter, XPath /in:inputs/in:param[@name='StartPage'] -->
<in:param name="StartPage">a026ef51-7d02-421a-b505-e70bccea8576</in:param>
<!-- Function Call Result (0 ms), XPath /in:inputs/in:result[@name='GetPortfolioDetailsXml']/PortfolioDetails -->
<in:result name="GetPortfolioDetailsXml">
<PortfolioDetails Id="424a8001-619f-4722-922b-096c5d4ab8db" ExternalLink="http://www.accessalliedhealth.com.au/" Thumbnail="MediaArchive:27eb072a-8360-445f-be2f-e5fc7d42982d" Thumbnail.KeyPath="MediaArchive:27eb072a-8360-445f-be2f-e5fc7d42982d" xmlns=""/>
</in:result>
<!-- Function Call Result (0 ms), XPath /in:inputs/in:result[@name='SitemapXml']/Page -->
<in:result name="SitemapXml">
<Page Id="7e9565aa-4905-498f-84e9-29b823106d1f" Title="home" MenuTitle="home" UrlTitle="" Description="" ChangedDate="2013-01-28T21:31:06.8224576+10:00" ChangedBy="admin" URL="/c1mode(unpublished)" Depth="1" isopen="true" xmlns="">
<Page Id="141f96c6-05a0-435e-abf9-da9e5a62e8d4" Title="About" MenuTitle="about" UrlTitle="About" Description="" ChangedDate="2013-02-05T14:52:34.1180683+10:00" ChangedBy="admin" URL="/About/c1mode(unpublished)" Depth="2"/>
<Page Id="565f4b7e-284a-44e3-b031-39f1d2a84b90" Title="Websites" MenuTitle="websites" UrlTitle="Websites" Description="" ChangedDate="2013-01-28T15:43:47.7265295+10:00" ChangedBy="admin" URL="/Websites/c1mode(unpublished)" Depth="2"/>
<Page Id="9a8c12b7-779c-46f2-9e1e-aee1ff015bd4" Title="Portfolio" MenuTitle="portfolio" UrlTitle="Portfolio" Description="" ChangedDate="2013-02-06T17:09:01.7407404+10:00" ChangedBy="admin" URL="/Portfolio/c1mode(unpublished)" Depth="2" isopen="true">
<Page Id="91f4bf5e-4155-4fd5-a5f4-905fb375afff" Title="Item 1" MenuTitle="Item 1" UrlTitle="Item 1" Description="" ChangedDate="2013-02-06T13:02:52.7160005+10:00" ChangedBy="admin" URL="/Portfolio/Item-1/c1mode(unpublished)" Depth="3"/>
</Page>
</Page>
</in:result>
</in:inputs>