"Page" Asset + Format looks great on it's own... Until I include it in a page

matt.chappel's Avatar

matt.chappel

19 Jun, 2014 09:53 PM

When I pair a data-definition driven "page" asset with an XSLT format, I get the desired results.
But when I attempt to include this asset in a page, and assign the same XSLT format to a page region, nothing renders.

Additionally, when I try to add a "current page" index block to this region (to go along with the format), I get a bunch of unformatted text with no HTML markup.

I feel like I'm close! But maybe not?!

  1. 1 Posted by Ryan Griffith on 20 Jun, 2014 11:11 AM

    Ryan Griffith's Avatar

    Hi Matt,

    It sounds as though you will need the following (or confirm you have the following):

    • The page chooser's Render Content Depth field needs to be set to 4 or 5 to ensure the chosen page's structured data is included.
    • Because you are using an XSLT Format on a non-"DEFAULT" region, you will need a current page Index Block so the Format has access to the calling page's structured data. -Because you were seeing unformatted text within the HTML, your XSLT Format will need to be tweaked so that it only targets the relevant XML elements from the Index Block.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by matt.chappel on 20 Jun, 2014 01:59 PM

    matt.chappel's Avatar

    Ryan,

    Thanks so much for the reply. You confirmed what I was dreading: My XSL is bad.
    Here’s a screenshot of what happens on the page currently:

    I can see the content I need, which tells me my content depth is appropriate. It is highlighted in yellow below.

    [cid:[email blocked]]

    I’ve also attached my xsl format in hopes that you may be able to easily tell me what I need to change to get this working.

    Thank you for any guidance you may be able to provide.

    Regards,
    Matt

  3. 3 Posted by Ryan Griffith on 20 Jun, 2014 05:08 PM

    Ryan Griffith's Avatar

    Hi Matt,

    Looking over the screenshot, it does appear you will need to tweak your XSLT Format. This is pretty common though, so don't sweat it. When you have a moment, let's give the following a try and let me know how it works out:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    
        <xsl:template match="/system-index-block">
            <div id="example1">
                <ul class="example_menu" id="menu1">
                    <xsl:apply-templates select="//system-data-structure/collapsible_list_item"/>
                    <li class="footer">
                        <span></span>
                    </li>
                </ul>
            </div>
        </xsl:template>    
        <xsl:template match="collapsible_list_item">
            <li>
                <a class="collapsed">
                    <span class="faq_question">
                        <xsl:value-of select="item_heading"/>
                    </span>
                </a>
                <ul>
                    <li>
                        <p>
                            <xsl:value-of select="item_content"/>
                        </p>
                    </li>
                </ul>
            </li>
        </xsl:template>
        
    </xsl:stylesheet>
    

    Please let me know if you have any questions.

    Thanks!

  4. 4 Posted by matt.chappel on 23 Jun, 2014 01:59 PM

    matt.chappel's Avatar

    Ryan!

    Thanks so much! That XSLT did the trick.
    Admittedly, I’m a beginner in the XSLT realm. Would you mind explaining the logic behind your XSLT markup?

    Thanks again. You’re a life-saver.

    Regards,
    Matt

  5. 5 Posted by Ryan Griffith on 23 Jun, 2014 03:09 PM

    Ryan Griffith's Avatar

    Not a problem at all, Matt.

    This template will match the root system-index-block element provided by the Index Block, generate the wrapper HTML for your menu, and within the wrapper call <xsl:apply-templates> on //system-data-structure/collapsible_list_item, which basically says: "apply the collapsible_list_item template for all system-data-structure/collapsible_list_item items, at any level".

    This template is called from the above template with the context of every collapsible_list_item item element found and renders the items.

    Please let me know if you have any questions.

    Thanks!

  6. 6 Posted by matt.chappel on 23 Jun, 2014 03:44 PM

    matt.chappel's Avatar

    That makes sense... I can see that the first <xsl:template> represents the wrapper html markup, then the <xsl:apply-templates> refers to the second <xsl:template>, which represents each item created by the user via the Data Definition. Is that accurate?

    Thanks for your help! It all makes sense now.

  7. 7 Posted by Ryan Griffith on 23 Jun, 2014 05:48 PM

    Ryan Griffith's Avatar

    You are correct, Matt. Think of <xsl:apply-templates> as a loop that is calling the associated template for every element found. This could also be written using <xsl:for-each>, but this way is a bit cleaner (and I've heard more efficient).

    Please let me know if you have any questions.

    Thanks!

  8. Ryan Griffith closed this discussion on 01 Jul, 2014 08:36 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac