Random photo from selected gallery

rated by 0 users
Answered (Verified) This post has 1 verified answer | 6 Replies | 3 Followers

Top 500 Contributor
84 Posts
Points 1,170
muro1 posted on Sat, Jul 28 2007 8:25 PM

Hi,

I am able to display a random photo from the galleries on my home page using the <CSGallery:GalleryPostData /> tag.

Now, I'd like to choose a specific gallery where the random image should be pulled from. I have looked at the properties of  CSGallery:GalleryPostData but couldn't find any filtering option. Should I use a <QueryOverrides> ? Can someone show me how to do this?

Thank you.

 Jacques 

  • | Post Points: 20

Answered (Verified) Verified Answer

Top 10 Contributor
3,399 Posts
Points 65,060
CS Developers
Answered (Verified) Ben Tiedt replied on Thu, Aug 9 2007 10:28 AM

The <CSGallery:GalleryPostData UseRandomPost="true" /> will retrieve a random image based on the context of the control -- if the control is within the context of a Gallery or a Gallery+Album, it will load a random photo from that Gallery or Gallery+Album.

To set the context, you can use a <CSGallery:GalleryList /> control.  For example, to specify a specific gallery from which to load the random photo, you could use:

<CSGallery:GalleryList runat="server">
  <QueryOverrides SectionApplicationKey="[APPLICATION_KEY_OF_PHOTO_GALLERY]" />
  <ItemTemplate>
     <CSGallery:GalleryPostData runat="server" UseRandomPost="true" Property="Subject" />
  </ItemTemplate>
</CSGallery:GalleryList>

Ben Tiedt's Blog

  • | Post Points: 35

All Replies

Top 10 Contributor
3,399 Posts
Points 65,060
CS Developers
Answered (Verified) Ben Tiedt replied on Thu, Aug 9 2007 10:28 AM

The <CSGallery:GalleryPostData UseRandomPost="true" /> will retrieve a random image based on the context of the control -- if the control is within the context of a Gallery or a Gallery+Album, it will load a random photo from that Gallery or Gallery+Album.

To set the context, you can use a <CSGallery:GalleryList /> control.  For example, to specify a specific gallery from which to load the random photo, you could use:

<CSGallery:GalleryList runat="server">
  <QueryOverrides SectionApplicationKey="[APPLICATION_KEY_OF_PHOTO_GALLERY]" />
  <ItemTemplate>
     <CSGallery:GalleryPostData runat="server" UseRandomPost="true" Property="Subject" />
  </ItemTemplate>
</CSGallery:GalleryList>

Ben Tiedt's Blog

  • | Post Points: 35
Top 500 Contributor
84 Posts
Points 1,170
muro1 replied on Sat, Aug 11 2007 3:04 AM

This is exactly what I was looking for. Thank you Ben. 

  • | Post Points: 20
Not Ranked
4 Posts
Points 295
baotao replied on Tue, Aug 14 2007 4:38 AM

maybe you need auto display:

    <script type="text/javascript">
        //<![CDATA[   
        function timerFunction()
        {
            <%=CSControlUtility.Instance().FindControl(this, "PhotoUpdater").ClientID %>.Reload();
            window.setTimeout('timerFunction();', 10000);
            return false;
        }

        window.setTimeout('timerFunction();', 10000);

        //]]>
    </script> 

  • | Post Points: 20
Top 500 Contributor
84 Posts
Points 1,170
muro1 replied on Sat, Aug 18 2007 4:04 AM

baotao:
maybe you need auto display:
 

That's helpful too, thanks, baotao. 

  • | Post Points: 5
Not Ranked
3 Posts
Points 30
amigooo replied on Sun, Dec 30 2007 6:34 AM

 hi ben - please tell me: where can i find the application key?

  • Filed under:
  • | Post Points: 20
Top 10 Contributor
2,456 Posts
Points 27,770
MVPs
Just navigate to your gallery - the application key will be shown in the path, e.g. http://www.mysite.com/photos/[application key]/default.aspx

-- Commerce for Community Server at last! 4-roads.com Gary

  • | Post Points: 5
Page 1 of 1 (7 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com