Copied to clipboard

Flag this post as spam?

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


  • Elad Lachmi 112 posts 144 karma points
    Jun 29, 2011 @ 12:38
    Elad Lachmi
    0

    media picker in to javascript

    Hi,

    I have a web page which has a slideshow image background.

    I load the slideshow with the following code:

    $(document).bgStretcher({
    images: ['images/bg1.jpg', 'images/bg2.jpg', 'images/bg3.jpg', 'images/bg4.jpg' ], imageWidth: $(window).width(), imageHeight: $(window).height() });

    I would like to populate the images property from a media picker, which the editor will populate.

    Any one have a suggestion on how to do this? I'm a little lost TBH.

    Thank you!

  • Rich Green 2246 posts 4006 karma points
    Jun 29, 2011 @ 13:33
    Rich Green
    1

    Hi Elad,

    You can either a XSLT Macro, or a Razor macro to render out the mark up you need.

    Your template would be something like

      

      $(document).bgStretcher({
      images: [<umbraco:Macro Alias="getImages" runat="server"/>], imageWidth: $(window).width(), imageHeight: $(window).height()});

    Rich

  • Elad Lachmi 112 posts 144 karma points
    Jun 30, 2011 @ 07:26
    Elad Lachmi
    0

    Thank you!

    I have done several sites in Umbraco, but still find myself not looking in the right places...

  • Elad Lachmi 112 posts 144 karma points
    Jun 30, 2011 @ 08:05
    Elad Lachmi
    0

    I'm now stuck on the XSLT :(

    This is what I have going, but it's not outputing anything:

    <xsl:param name="currentPage"/>

        <xsl:template match="/imageList/multi-url-picker">
          <xsl:for-each select="/url-picker">

          <xsl:variable name="url"><xsl:value-of select="./url" /></xsl:variable>
          <xsl:value-of select="concat('&quot;', $url, '&quot;')" />
          </xsl:for-each>
        </xsl:template>

  • Rich Green 2246 posts 4006 karma points
    Jun 30, 2011 @ 09:22
    Rich Green
    0

    Hey Elad,

    First things first, you need to be using a data type that allows mutiple selections of images, something like uComponents MultiNodeTreePicker or DAMP.

    Which datatype are you using?

    Rich

  • Elad Lachmi 112 posts 144 karma points
    Jun 30, 2011 @ 09:29
    Elad Lachmi
    0

    I used the multi URL picker. I got it working.

    Here is the XSLT code, for future generations :)

    <xsl:param name="currentPage"/>
    <xsl:template match="/">
      <xsl:apply-templates select="$currentPage/ancestor-or-self::ContentPages/imageList/multi-url-picker" />
    </xsl:template>
          <xsl:template match="url-picker">
            <xsl:variable name="url"><xsl:value-of select="./url" /></xsl:variable>
            <xsl:value-of select="concat('&quot;', $url, '&quot;,')" />
        </xsl:template>
  • Rich Green 2246 posts 4006 karma points
    Jun 30, 2011 @ 10:53
    Rich Green
    1

    Nice work, glad you got it working :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies