Tag Cloud for items, searching items etc

Topics: Developer Forum, User Forum
Feb 20, 2008 at 6:46 PM
Hi Cristian

Have implemented a large image gallery using N2. All images are loaded into the DB as individual items and then presented as a collection on a single page (eg the parent item page).

Was wondering if I could implement a search feature so that images could be searched by name, and could even be tagged when uploaded and the tags then used to allow people to search the collection by tag..

What recommendations would you have for implementing something along these lines.

Thanks for your help///

excellent work!

Dom
Coordinator
Feb 20, 2008 at 9:22 PM
Hi Dom,

Interesting. First off searching items by name. Using the query api would probably work, e.g.

N2.Find.Items.Where.Title.Like("tagna%")...

Then about the tags. One solution would be using the detail collection feature:

public class GalleryImage : N2.ContentItem
{
		public IList Tags
		{
			get { return GetDetailCollection("Tags", true); }
		}
}

Having the tags list you could either just add strings...
image.Tags.Add("Tagname");
...or updating a separate collection of "TagItem"s
TagItem tag = GetOrCreateTag("Tagname");
tag.ImageCount++;
images.Tags.Add(tag);
The second option would allow you to aggregate some information.

To search items having a certain tag:
TagItem tag = GetTag("Tagname");
N2.Find.Items.Where.Detail("Tags").Eq(tag)

/Cristian
Jun 30, 2008 at 2:14 PM
Tag Cloud (and tagging) may be intersting in all contexts. a webpart should be usefull.