Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Luke Johnson 61 posts 80 karma points
    Jul 13, 2011 @ 19:51
    Luke Johnson

    Retrieve multiple pageFields with a single XSLT file

    I am looking for a way to retrieve multiple pagefields from the same node, to have them display on a different page. I have this working for a single page field. The code below fulfills the standard action of linking one node's content with another's.

    <xsl:template match="/">
        <xsl:variable name="source" select="/macro/source" />
        <xsl:variable name="homeNode" select="umbraco.library:GetXmlNodeById($source)" />
        <xsl:value-of select="$homeNode/pageContent" disable-output-escaping="yes" />

    In my website project, I have several school areas (/college, /seminary, /highschool, /distance) that need to offer admissions information. I also have an admissions area of the website, a sort of one-stop-shop for all things admissions, at /apply. I want to have all the content at /apply, and distribute the content with XSLT to /college/admissions, /seminary/admissions, ect...

    Some of these pages have many expanding menus, where a user sees only the title, clicks on it, and opens a div that contains lots of other information (as a way to keep the page from becoming overly text-heavy). Maybe I haven't set this up in the best way, but I have hard-coded each of these expanding menus into my template, and call the pageField for the menu's title and its content:

      <h2 class="trigger"><umbraco:Item field="expMenuTitle1" runat="server"/></h2>
      <div class="toggle_container">
        <div class="block">
          <umbraco:Item field="expMenuContent1" runat="server"/>

    Some pages like this have up to 20 of these hard-coded expanding menus. (It's a bit of a headache, but I'm just starting to get my footing in XSLT, so if there is a way to automatically generate this <h2 class = "trigger"> stuff as well, I am happy to hear that too!)

    In both /apply and, for example, /college/admissions, I have set up parallel templates. For instance, the actual content will be entered into /apply/how-to-enrol.aspx. This page has 10 expanding menus to match the expanding menu page /college/admissions/how-to-enrol.aspx.

    To make the transfer of information happen, I am having to create individual XSLT files and macros that call up each individual pageField, such as these:

    File 1


    <xsl:value-of select="$homeNode/apply-expMenu1" disable-output-escaping="yes" />



    File 2 ...


    <xsl:value-of select="$homeNode/apply-expMenu2" disable-output-escaping="yes" />



    This way, apply-expMenu2 from /apply/how-to-enrol.aspx feeds into /college/admissions/how-to-enrol.aspx. But having to do this for every single menu item is very time consuming.

    Is there a way to automate this process a bit more?

    Something like:


    <xsl:value-of select="$homeNode/apply-expMenu($number)disable-output-escaping="yes" />


    Thank-you for helping me with this confusing problem.

    If there is an easier way to set this up (such as some sort of <xsl:for-each> that would build the expanding menu markup around each pageField), I am happy to hear it.

  • Chriztian Steinmeier 2717 posts 8195 karma points MVP 4x admin c-trib
    Jul 13, 2011 @ 21:11
    Chriztian Steinmeier

    Hi Luke,

    There's definitely ways to do this - could you show us perhaps a screenshot of your Content tree, and a snippet of the HTML you hope to generate? Then it will be easier to provide some code samples etc. to get you going.


  • Luke Johnson 61 posts 80 karma points
    Jul 13, 2011 @ 23:02
    Luke Johnson

    Thanks, Chriztian!

    Here is the /apply/college content tree (it's not complete, but you get the idea):

    Here is the /college/admissions content tree. As you can see, the pages are named the same. So, "How to Enrol" from /apply/college will be sent to "How to Enrol" /college/admissions.

    Here is the XSLT I am currently using to get info from one pageField to another:

        <xsl:template match="/">
        <xsl:variable name="source" select="/macro/source" />
        <xsl:variable name="homeNode" select="umbraco.library:GetXmlNodeById($source)" />
        <xsl:value-of select="$homeNode/pageContent" disable-output-escaping="yes" />

    Here is a snippet of the HTML I use for the expanding menus (which I would like to generate through XSLT):

        <!-- this is one complete unit, title and expandable div -->
        <!-- h2.trigger forms the titlebar which the user would click on to expand -->
        <h2 class="trigger">
    <umbraco:Item field="sourceFeed-ExpandingMenu1" runat="server"/>
    </h2> <!-- div.toggle_container contains the content; div.block just supplies some extra formatting --> <div class="toggle_container"><div class="block"> <umbraco:Item field="sourceFeed-ExpandingMenu1" runat="server"/> </div></div>

    And here are the menus when they are in use:
    (A live example of these menus is found on our current website:


    I hope this gives some bearings. Please let me know if any other information would be helpful!

Please Sign in or register to post replies

Write your reply to: