I am looking for a way to display Relations to content editors and use this in conjunction with Umbraco Relation Editor package to make a good ui for editing relations.
Is there something I am missing (a package or some functionality in Umbraco) to display these Relations to the user?
I looked through Release Notes up to 7.2, searched this site, looked through all compatible packages, searched the web, etc. I can't find anything. It seems easy enough to build if I can figure out the extension points of content loading in the backend or build a "fake" property editor that shows a grid view of relations.
If there is something out there that will save me the time, I am willing to take a look at it though!
Hi, Phil. Thanks for your response. I think the concept is similar, but I am wanting to display Relations that are created through the RelationService.
This is a bit different (mapping documents for different cultures) unless I am missing something. I can look in the code files if they are available to see if there is anything I could use to build something custom.
An old question I know but I have been just been setting up relations on an Umbraco 7.2.0 build and you can indeed view existing relations within the back-office. It is found in the Developer section , under Relation Types.
For example if you have a Relation Type called 'Relate Document On Copy' (the default Relation Type for relating copies of nodes), by clicking on the relations tab you can see all the existing relations for that Relation Type.
Unfortunately you cannot delete/remove relations from this screen, only view them. If you want the ability to remove/delete relations, you could utilize the Trashed Event within the Content Service to fire the delete method within the Relations Service to remove relations for that node when trashed or deleted.
For example:
public class CustomEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ContentService.Trashed += ContentService_Trashed;
}
private void ContentService_Trashed(IContentService sender, MoveEventArgs<IContent> args)
{
var relationService = ApplicationContext.Current.Services.RelationService;
foreach (var trashedNode in args.MoveInfoCollection)
{
var relations = relationService.GetByParentOrChildId(trashedNode.Entity.Id)
.Where(r => r.RelationType.Alias == "myRelationTypeAlias");
if (relations != null & relations.Any())
{
foreach (var relation in relations)
{
relationService.Delete(relation);
}
}
}
}
}
By using this method you would actually delete (trash) the node as well as the relations it had. However you could then restore the node from the recycle bin, or you could have made an 'unrelated' copy prior to trashing the node and just use that.
Is there a way to display Relations in v7?
I am looking for a way to display Relations to content editors and use this in conjunction with Umbraco Relation Editor package to make a good ui for editing relations.
Is there something I am missing (a package or some functionality in Umbraco) to display these Relations to the user?
I looked through Release Notes up to 7.2, searched this site, looked through all compatible packages, searched the web, etc. I can't find anything. It seems easy enough to build if I can figure out the extension points of content loading in the backend or build a "fake" property editor that shows a grid view of relations.
If there is something out there that will save me the time, I am willing to take a look at it though!
Thanks!
Brice
Hi Brice,
I haven't tried this package and only just saw it for the first time yesterday but maybe this is what you're looking for?
http://our.umbraco.org//projects/backoffice-extensions/culturemapper
Cheers,
Phill
Hi, Phil. Thanks for your response. I think the concept is similar, but I am wanting to display Relations that are created through the RelationService.
This is a bit different (mapping documents for different cultures) unless I am missing something. I can look in the code files if they are available to see if there is anything I could use to build something custom.
Hi Brice,
An old question I know but I have been just been setting up relations on an Umbraco 7.2.0 build and you can indeed view existing relations within the back-office. It is found in the Developer section , under Relation Types.
For example if you have a Relation Type called 'Relate Document On Copy' (the default Relation Type for relating copies of nodes), by clicking on the relations tab you can see all the existing relations for that Relation Type.
Unfortunately you cannot delete/remove relations from this screen, only view them. If you want the ability to remove/delete relations, you could utilize the Trashed Event within the Content Service to fire the delete method within the Relations Service to remove relations for that node when trashed or deleted.
For example:
By using this method you would actually delete (trash) the node as well as the relations it had. However you could then restore the node from the recycle bin, or you could have made an 'unrelated' copy prior to trashing the node and just use that.
I hope this is of help to someone.
Cheers,
Nathan
is working on a reply...