locked
Need help with Album page in Personal Website Starter Kit RRS feed

  • Question

  • User-758507629 posted

    On the Albums.aspx page,  the gridview shows all albums, i would like it to only show the latest album, In other words, i would like the user to only see the album they have just created and not all the other albums.

    Is this possible?

     

    Tuesday, October 16, 2007 2:51 PM

Answers

  • User-1489493332 posted

     Ok, let's take a look in PhotoManager.vb.

     In most of the functions (like GetPhoto, GetAlbums...etc) you'll see the following two lines.

    Dim Filter As Boolean = Not (HttpContext.Current.User.IsInRole("Friends") Or HttpContext.Current.User.IsInRole("Administrators"))
    command.Parameters.Add(New SqlParameter("@IsPublic", Filter))

    That simply says, if the current user is a member of Friends or Administrators the next line which filters for public albums gets disabled in a away.

    So you need to remove the HttpContext.Current.User.IsInRole("Friends") out of the above line so it becomes,

    Dim Filter As Boolean = Not (HttpContext.Current.User.IsInRole("Administrators"))

    That will make the private albums only appear to the Administrators.

    Remember to do the same to all functions in PhotoManager.vb

    Cheers,

    Hs2K

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 18, 2007 5:43 PM

All replies

  • User-1489493332 posted
    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>When a new Album is created it's assigned a unique AlbumID which is stored in the first column of the Albums table. Since the newest album will have the highest AlbumID, you can simply sort by AlbumID and use highest returned ID to list the latest Album.</o:p><o:p>I hope this helps.</o:p><o:p></o:p><o:p></o:p><o:p>Regards,</o:p><o:p></o:p><o:p>Hs2k</o:p>
    Tuesday, October 16, 2007 7:22 PM
  • User-758507629 posted

    Thanks for your help.

    I am not sure were to find the sort property.I have searched the the gridview code and can't find it.

    I would like to have the highest numbered Album first by default or even better, i would like to only display the highest numbered album..

    Wednesday, October 17, 2007 9:29 AM
  • User-1489493332 posted

    You’ll need to edit the GetAlbums stored procedure in your database.

    To get the sorting you can add the ‘Order By’ command near the end. So your new stored procedure will look like this,

    	GROUP BY 
    		[Albums].[AlbumID], 
    		[Albums].[Caption], 
    		[Albums].[ALat], 
    		[Albums].[ALon], 
    		[Albums].[IsPublic]
    	ORDER BY 
    	[Albums].[AlbumID] DESC
    RETURN

    And if you only want to show the first album, then you can use the ‘SELECT TOP 1’ near the start of the GetAlbums stored procedure as below,

    	SELECT TOP 1
    		[Albums].[AlbumID], 
    		[Albums].[Caption],

    Hope that helps,
    Hs2K

    Wednesday, October 17, 2007 6:01 PM
  • User-758507629 posted

     

    That  work great!  Thanks.

    I have one more question, How do I only display only the "public" albums to people that are logged in as "friends".  Currently,  "friends" can see all the albums, like the "Administrator". I only want  friends to see albums that have been marked as public.

     

    Thanks again for your help

    Thursday, October 18, 2007 11:00 AM
  • User-1489493332 posted

     Ok, let's take a look in PhotoManager.vb.

     In most of the functions (like GetPhoto, GetAlbums...etc) you'll see the following two lines.

    Dim Filter As Boolean = Not (HttpContext.Current.User.IsInRole("Friends") Or HttpContext.Current.User.IsInRole("Administrators"))
    command.Parameters.Add(New SqlParameter("@IsPublic", Filter))

    That simply says, if the current user is a member of Friends or Administrators the next line which filters for public albums gets disabled in a away.

    So you need to remove the HttpContext.Current.User.IsInRole("Friends") out of the above line so it becomes,

    Dim Filter As Boolean = Not (HttpContext.Current.User.IsInRole("Administrators"))

    That will make the private albums only appear to the Administrators.

    Remember to do the same to all functions in PhotoManager.vb

    Cheers,

    Hs2K

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 18, 2007 5:43 PM
  • User-758507629 posted

    Again, That worked great. My site is written in c# but i was able to find what you were talking about. Now my site works perfect.

    Thanks again!

    Friday, October 19, 2007 11:23 AM
  • User1174473040 posted

     Ok, let's take a look in PhotoManager.vb.

     In most of the functions (like GetPhoto, GetAlbums...etc) you'll see the following two lines.

    Dim Filter As Boolean = Not (HttpContext.Current.User.IsInRole("Friends") Or HttpContext.Current.User.IsInRole("Administrators"))
    command.Parameters.Add(New SqlParameter("@IsPublic", Filter))

    That simply says, if the current user is a member of Friends or Administrators the next line which filters for public albums gets disabled in a away.

    So you need to remove the HttpContext.Current.User.IsInRole("Friends") out of the above line so it becomes,

    Dim Filter As Boolean = Not (HttpContext.Current.User.IsInRole("Administrators"))

    That will make the private albums only appear to the Administrators.

    Remember to do the same to all functions in PhotoManager.vb

    Cheers,

    Hs2K

     

     

     

    Any suggestions or ideas as to editing this code to allow me to control the roles from the admin section instead of hard coding it? 

    Using VWD2008 and VB

    Friday, February 29, 2008 5:05 PM