Organising Galleries.

Topics: Developer Forum, User Forum
Apr 19, 2011 at 10:35 AM

Hi I remember a thread on this before but I can't find it again.

What I'd  like to do is organise my Galleries by "Last First" as opposed to the default "First First" I remember someone writing a plugin that allowed you to promote pictures one place at a time, but to completely reverse the order would be easier. Has anyone done this? and if so has anyone a code sample for how they did it?

 

Martin

Apr 21, 2011 at 1:36 PM

Hi Martin,

Try following couple of steps:

1. Add following function to App_Code/Sections/Gallery.cs after GetGalleryEntries() function,

public DataTable GetReversedGalleryEntries()
{
    DataTable source = GetGalleryEntries();
    DataTable reversed = new DataTable("ReversedGalleryEntries");

    foreach (DataColumn col in source.Columns)
    {
	DataColumn column = new DataColumn(col.ColumnName, col.DataType);
	column.Unique = col.Unique;
	reversed.Columns.Add(column);
    }

    for (int index = source.Rows.Count - 1; index >= 0; index--)
    {
	DataRow row = reversed.NewRow();

	foreach (DataColumn col in source.Columns)
	{
	    row[col.ColumnName] = source.Rows[index][col.ColumnName];
	}

	reversed.Rows.Add(row);
	row.AcceptChanges();
    }

    return reversed;
}

2. In SectionControls/Gallery.ascx.cs, search

_section.GetGalleryEntries();

and replace with,

_section.GetReversedGalleryEntries();

 

N'Joyyy

Amol

Jun 7, 2011 at 9:36 AM

Thanks Amol,

works a treat, it got me to thinking about a random image shuffler, in silverlight, going to have  a look into that one next :)