MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

MonoX Social Events Question  (Mono Support )

Viewed 15062 time(s), 2 post(s) 6/9/2011 6:47:52 PMby GTWelsh
GTWelsh

GTWelsh

6/9/2011 6:55:34 PM
Hello,

I'm really quite new so I'm stuck on this...


I would like to have site-wide updates on the activities of all members, on the home page, available to view for everybody, even users that are not logged in,

At the moment the best I can do is, when your not logged in you get nothing, and when you are you get your friends updates. This is fine for the social wall page, but for the homepage I would like it to be a complete collection of updates for everybody to view like I said.

EDIT:

Also, would it be possible to add a like button (Nothing to do with facebook)?
So it appears on the user activities page ?


Sorry adding a question that isn't related to much with the title.


Thank you

Chris
This content has not been rated yet. 
25 Reputation 4 Total posts
denis

denis

6/9/2011 8:24:15 PM
Hi Chris,
Event/activities stream Web part currently shows only the activities of the active users and users in his social network (the display of the events for the active user can be turned off, so only a list of activities of his friends is shown). By default it cannot show all activities without filtering them, but it is relatively easy to achieve by implementing a custom Web part based on the default MonoX event.ascx Web part.
You would have to know how to open a custom MonoX project and add Web parts and other classes to it. There are quite a few tutorials on this topic in our blog section, and you should check these two: http://www.mono-software.com/blog/post/Mono/95/Building-a-custom-ASP-NET-project-based-on-MonoX/ and http://www.mono-software.com/blog/post/Mono/93/Building-a-custom-Web-part/
There are several steps in this process:
1. make your own repository by inheriting from the MonoSoftware.MonoX.Repositories.EventRepository and add the following method. Its behavior is similar to the original GetEvents method, but does not filter anything:

public virtual EntityCollection<SnEventEntity> GetEvents(int numberOfEvents)
{
    EntityCollection<SnEventEntity> events = new EntityCollection<SnEventEntity>(new SnEventEntityFactory());
    IPrefetchPath2 prefetchPath = new PrefetchPath2(EntityType.SnEventEntity);
    prefetchPath.Add(SnEventEntity.PrefetchPathFriendAspnetUsers);
    prefetchPath.Add(SnEventEntity.PrefetchPathBlogPost);
    prefetchPath.Add(SnEventEntity.PrefetchPathSnAlbum);
    prefetchPath.Add(SnEventEntity.PrefetchPathSnFile);
    prefetchPath.Add(SnEventEntity.PrefetchPathSnGroup);
    prefetchPath.Add(SnEventEntity.PrefetchPathAspnetUsers).SubPath.Add(AspnetUsersEntity.PrefetchPathUserProfile);
    prefetchPath.Add(SnEventEntity.PrefetchPathSnDiscussionBoard);
    prefetchPath.Add(SnEventEntity.PrefetchPathSnDiscussionTopic);
    ISortExpression sortExpression = new SortExpression(new SortClause(SnEventFields.DateCreated, null, SortOperator.Descending));
    FetchEntityCollection(events, null, numberOfEvents, sortExpression, prefetchPath);
    return events;
}

2. make your own custom Web part by inhering from the MonoSoftware.MonoX.ModuleGallery.SocialNetworking.Events. Override the BindData methid like this:

public override void BindData()
    {
        MonoXCacheManager cacheManager = MonoXCacheManager.GetInstance(CacheKeys.Events.EventList, this.CacheDuration);
        EventRepository repository = EventRepository.GetInstance();
        Guid userId = this.UserId;
        if (userId == Guid.Empty)
            userId = SecurityUtility.GetUserId();
        EntityCollection<SnEventEntity> events = cacheManager.Get<EntityCollection<SnEventEntity>>(this.NumberOfEventsToShow);
        if (events == null)
        {
            events = repository.GetEvents(this.NumberOfEventsToShow);
            cacheManager.Store(events, this.NumberOfEventsToShow);
        }
        if (events != null)
        {
            lvItems.DataSource = events;
            lvItems.DataBind();
        }
    }

You can now place the inherited Web part wherever you want.

As for the "like" functionality, we will try to put together a small sample soon. The infrasctucture is ready for it, as the existing rating functionality (as seen here in the discussion forum and in the blog page) is basically a more complex version of it.


This content has not been rated yet. 
7207 Reputation 956 Total posts