Copied to clipboard

Flag this post as spam?

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


  • René 327 posts 852 karma points
    Oct 16, 2012 @ 10:45
    René
    0

    just add Media type aliases

    Hi 
    I have a question witch have been ansvered a lot of times :-(
    But i´m stucked here
    I have got code earlier..  
    By question if there is someone who can come up with a hint in the right direction about this part
    "just add Media type aliases"
    I souds so easy but i cant figure out how
    A small example would be great.
    tanks for this great forum
    René
    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet
            version="1.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:umb="urn:umbraco.library"
            exclude-result-prefixes="umb"
    >
    
            <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    
            <xsl:param name="currentPage" />
    
      <xsl:variable name="mediaFolder" select="/macro/mediaFolder" />
    
            <xsl:template match="/">
              <xsl:if test="$mediaFolder[Folder]">
                            <xsl:variable name="media" select="umb:GetMedia($mediaFolder/Folder/@id, true())" />
    
                            <!-- If no errors, this will run the Folder template below -->
                            <xsl:apply-templates select="$media[not(error)]" />
    
                    </xsl:if>
            </xsl:template>
    
            <!-- Template for the folder -->
            <xsl:template match="Folder">
                    <ul  class="client-logo">
                            <!-- Run templates for individual items (just add Media type aliases) -->
                            <xsl:apply-templates select="File | Image" />
              </ul>
    
            </xsl:template>
    
            <!-- Template for items - you can create individual templates to render them differently -->
            <xsl:template match="File | Image">
              <li><img alt="{imageAltTag}" src="{umbracoFile}"/></li>     
            </xsl:template>
    
    
    </xsl:stylesheet>
  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Oct 16, 2012 @ 22:23
    Chriztian Steinmeier
    0

    Hi René,

    I recognize my code from miles away :-)

    What the "just add Media type aliases" means, is if you've created a PDFFile media type or a WordDoc media type, and you want to process those like the others, then you should add those aliases to the apply-templates line and the item template, like this:

    <xsl:apply-templates select="File | Image | PDFFile | WordDoc" />
    
    ...
    
    <xsl:template match="File | Image | PDFFile | WordDoc">
        ...
    </xsl:template>

    Hope this clears up some confusion, otherwise don't hesitate to ask again.

    /Chriztian

  • René 327 posts 852 karma points
    Oct 17, 2012 @ 07:43
    René
    100

    HI 

    Yes it is your own code.. 

    Well - that's what you meant, tanks. 

    René

Please Sign in or register to post replies

Write your reply to:

Draft