Copied to clipboard

Flag this post as spam?

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


  • Sachin 19 posts 49 karma points
    Dec 10, 2009 @ 07:58
    Sachin
    0

    Query related to photo gallery

    Hi All,

    I am created a photo gallery. It have got albums and photos. What I want to achieve is to display a one photo on the album page from the photos that are present in that album. How can I do this?

    Prompt response would be greatly appreciated.

    Thanks in advance,

    Kind Regards,

  • Paul Blair 466 posts 731 karma points
    Dec 10, 2009 @ 09:01
    Paul Blair
    0

    There are 2 ways I can think of you can arrange this depending on your needs. They are:

    1.) randomly select any of the albums photos

    2.) have the content editor select which photo is displayed on the photo page

    To achieve this:

    1.) try something like this:

    <msxsl:script implements-prefix='yourprefix' language='CSharp'>
        <![CDATA[
    public int randomNode(int limit)
    {
    DateTime tmeNow = DateTime.Now;
    int mls = tmeNow.Millisecond;
    Random rndNumber = new Random(mls);
    return rndNumber.Next(1, limit + 1);
    }

    ]]>
      </msxsl:script>

      <xsl:template match="/">
        <xsl:variable name="AdGroup" select="/macro/source/node/@id"/>
        <xsl:variable name="collection" select="umbraco.library:GetMedia($AdGroup, 'true')/node"/>
        <xsl:variable name="selectedNode" select="yourprefix:randomNode(count($collection))"/>

        <xsl:for-each select="$collection">
          <xsl:if test="position() = number($selectedNode)">
            <img>
              <xsl:attribute name="src">
                <xsl:value-of select="./data[@alias='umbracoFile']"/>
              </xsl:attribute>
              <xsl:attribute name="alt">
                <xsl:value-of select="@nodeName"/>
              </xsl:attribute>
            </img>

            </xsl:if>
        </xsl:for-each>

      </xsl:template>

    2.) Within the Settings section of Umbraco you can add node types in the Media types section the same as you would for document types. Create a new node type similar to Folder called Album. Add a media picker property to album and allow albums to have image nodetypes.

    Cheers

    Paul

     

Please Sign in or register to post replies

Write your reply to:

Draft