Nibble

New Package - Related Media

Based on the related links datatype that’s been added to umbraco v4.

This is a similar datatype but for selecting media, so a multiple media picker.

relatedmedia

You can add media by setting a caption and selecting a media item. Very similar to the related links.

The package will also install a xslt and marco that shows how to use xslt to display the stored media.

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE xsl:stylesheet [
  &lt;!ENTITY nbsp “&#x00A0;”>
]>
<xsl:stylesheet
    version=”1.0″
    xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”
    xmlns:msxml=”urn:schemas-microsoft-com:xslt”
    xmlns:umbraco.library=”urn:umbraco.library”
    exclude-result-prefixes=”msxml umbraco.library”>
 
 
  <xsl:output method=”xml” omit-xml-declaration=”yes” />
 
  <xsl:param name=”currentPage”/>
  
  <!– Input the related links property alias here –>
  <xsl:variable name=”propertyAlias” select=”string(’relatedmedia’)”/>
  
  <xsl:template match=”/”>
 
    <!– The fun starts here –>
    <ul>
      <xsl:for-each select=”$currentPage/data [@alias = $propertyAlias]/media/item”>
        <li>
          <xsl:element name=”a”>
                <xsl:attribute name=”href”>
                  <xsl:value-of select=”umbraco.library:GetMedia(./@id,’false’)/data [@alias = ‘umbracoFile’]”/>
                </xsl:attribute>
            <xsl:value-of select=”./@title”/>
          </xsl:element>
        </li>
      </xsl:for-each>
    </ul>
 
  </xsl:template>
 
</xsl:stylesheet>

 

Related Media Package: download

10 Comments so far

  1. David Conlisk on April 8th, 2009

    Nice work - very useful. How do you have the time to create all of these while running a business? Perhaps you could create a package that allows me to have more time to release packages while keeping clients happy too :)
    David

  2. Dan on April 8th, 2009

    Like you read my mind, I needed something like this just now!

    Cheers,
    Dan

  3. Nik on May 22nd, 2009

    Great work (as usual)!

    Have you considered merging it with NÖRD’s multiple file uploader or any other upload function (could even be you zip uploader)?

    If you’re willing to share some code I’d be happy to give it a try! ;)

  4. Si on June 18th, 2009

    Sounds like exactly what I need.

    However when I add the package on a new Umbraco installation I’m not getting the datatype show up. The macro and XSLT are showing though. Any help you can give?

  5. Ben on June 19th, 2009

    Hey Si,
    Go to Data Types in Developer, create a new DataType and choose Related Media as the render control. You should then be good to go :)

  6. Brent on March 15th, 2011

    I was looking at doing this myself, but this was a huge help. I did have a problem using it with Umbraco 4.6 (probably because of the XML schema changes) so I had to modify the XSLT as follows:

  7. IAMMRBONGO on April 12th, 2011

    Hi all,
    Having a bit of trouble getting this to work umbraco 4.5 after upgrading. Any advice? I can’t see any compatibility information anywhere.

  8. Andy Wilde on May 31st, 2011

    I’m having a problem viewing the content in v4.5. The xml is being stored as the list of items I have selected is shown in the editor but the only content I get rendered is ”.

    I have reinstalled and checked the alias name in the XSLT several times but still no rendered content, any help would be greatly appreciated.

  9. Wendy on August 19th, 2011

    I am trying to implement this is Umbraco 4.5 but keep getting an empty . I replaced the xslt as Brent suggested here (http://www.anterec.com/company-blog/umbraco-nibbles-relatedmedia.aspx) but it still won’t work. Any help would be appreciated.

  10. Anterec Software Development Team on November 7th, 2011

    @Wendy - we’ve double checked our code and it seems to be fine. The Umbraco XML schema changed from version 4.5, so older XSLT files can stop working.

    Take a look at our post at http://www.anterec.com/company-news/2011/3/15/umbraco-nibbles-relatedmedia.aspx for our 4.5 (and higher) version of the XSLT, but remember that you still need to perform the other configuration steps as described here.

Leave a Reply