I've some troubles setting up ContentLinks between a custom module (Group) and an Image. I was able to set up a proper link between them using this code:
var groupLive = manager.GetGroups().Where(x => x.Username ==
.emailAddress.Text && x.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).FirstOrDefault();
var imageLive = librariesManager.GetImages().Where(x => x.Title == imageName && x.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).FirstOrDefault();
var contentLinkManager = ContentLinksManager.GetManager();
var link = contentLinkManager.GetContentLink(groupLive.Id,
link = contentLinkManager.CreateContentLink(
, groupLive, imageLive);
link.ChildItemId = image.Id;
I don't know if this is the right way, but it seems the only way that is working. I also saw an available override on the Group entity, called 'CreateContentLink', but nothing happens.
Now the case is that I'm having a 'register form'. With this form I register a new 'Group'. Besides all information that can be filled in, I also have the ability to upload a photo (avatar).
I work with the ContentLifeCycle, so after I create a new group, I checkout a temp version, edit the properties, checkin the temp and finally publish the master. You can see in my code that I (again) lookup the group and the image, because my findings are that I need to create a ContentLink based on the 'Live' versions of the content. If I don't do this, I create a link between the 'Master' version, which then don't show up in the rest of my site.
Is there any smart way to add new content items and get the guid ID's of the 'Live' versions, without calling the 'GetGroups' and 'GetImages' and so on?
Hope it is clear what my problem is. It works for now, but it does seem a bit too much code.
Anyone who knows some more on this topic?