New to Umbraco and just completed my first plug-in, but now have been asked to so something a bit more advanced.
I want to build a plug-in that can fetch and then list (in a grid) some details of the child items below the item it's placed on.
I essence, I want to create similar functionality to enabling list-view mode on a document-type, but as a plug-in I can place on a document-type's property tab, so I don't need to disable the standard tree-view mode just to see a (possibly clickable) listing of an item's children.
Basically, I'm looking for some pointers on how to fetch data on the child items below the current item, from a plug-in.
Once I have the data, I would imagine the grid/angular stuff should be fairly straight forward.
If you include the EntityService in your angular controller it has a GetChildren method that you can use to get the children of the current page you are:
To get the id of the current item being edited in the backoffice, you should add the editorState helper to your controller, and then you can use:
editorState.current.id
be aware that when a page is first created in Umbraco this won't have a value, but then nor will it have children! so just need to put a check in on whether the id is populated, before using the entityservice to look for children.
Thanks for that, a ui resource seems like it might meet the requirements.
Would I be correct in assuming that getting the current content-node's ID for the property-editor's controller to use as its starting point, should be done using:
Just looking at the data that returns, my first guess would be that parentId of the property-editor's current state, refers to the content item it's sitting on, and that I can use that as the node to request child info on, using the method entiyResource.getChildren(parentId, type) - but I don't know it's that's a reliable value to use?
Of course, I'll also need a reliable way to know if the property-editor is being displayed in Document or Document-Type mode... but one step at a time.
Sorry for the confusion totally pasted the wrong link, and as Nathan points out, completely meant entityResource.
If you are now looping through the properties and finding a value in the format:
umb://document/abc12d3ef4567890e1f2345g678hi901
then this is the new Umbraco UDI a unique identifier for a content item (to eventually replace integer ids everywhere), my guess is the property that has this value is a Content Picker, this property type, allows editors to pick other content nodes that are related to the current content item... so you'd need to make a further request to retreive this picked objects details if you need to display any of it's details in your listview.
Yes, it's one of those xxxx2 content pickers. Actually, there are quite a few properties I need to access values for, with .config.idType = "udi"
I have to admit to being a bit stuck at the moment. I can't seem to find a BackOffice Resource, Service or Helper that addresses this, and am not sure where to go from here.
Get Content Items from Plug-In
New to Umbraco and just completed my first plug-in, but now have been asked to so something a bit more advanced.
I want to build a plug-in that can fetch and then list (in a grid) some details of the child items below the item it's placed on.
I essence, I want to create similar functionality to enabling list-view mode on a document-type, but as a plug-in I can place on a document-type's property tab, so I don't need to disable the standard tree-view mode just to see a (possibly clickable) listing of an item's children.
Basically, I'm looking for some pointers on how to fetch data on the child items below the current item, from a plug-in.
Once I have the data, I would imagine the grid/angular stuff should be fairly straight forward.
Hi MB
If you include the EntityService in your angular controller it has a GetChildren method that you can use to get the children of the current page you are:
https://our.umbraco.com/apidocs/csharp/api/Umbraco.Core.Services.EntityService.html#UmbracoCoreServicesEntityServiceGetChildrenSystemInt32UmbracoCoreModelsUmbracoObjectTypes_
To get the id of the current item being edited in the backoffice, you should add the editorState helper to your controller, and then you can use:
editorState.current.id
be aware that when a page is first created in Umbraco this won't have a value, but then nor will it have children! so just need to put a check in on whether the id is populated, before using the entityservice to look for children.
regards
Marc
Cheers.
I'm not sure I understand how the C# EntityService API relates to the angular controller, but that gives me a starting point to investigate.
Try here => https://our.umbraco.com/apidocs/ui/#/api/umbraco.resources.entityResource
Thanks for that, a ui resource seems like it might meet the requirements.
Would I be correct in assuming that getting the current content-node's ID for the property-editor's controller to use as its starting point, should be done using:
https://our.umbraco.com/apidocs/ui/#/api/umbraco.services.editorState
Just looking at the data that returns, my first guess would be that parentId of the property-editor's current state, refers to the content item it's sitting on, and that I can use that as the node to request child info on, using the method entiyResource.getChildren(parentId, type) - but I don't know it's that's a reliable value to use?
Of course, I'll also need a reliable way to know if the property-editor is being displayed in Document or Document-Type mode... but one step at a time.
Managed to make progress and drilled down to the document, and started extracting property values.
All was going well until I hit some properties with a value along the lines of: umb://document/abc12d3ef4567890e1f2345g678hi901
What do I need to use now to get the actual value ?
Hi MB
Sorry for the confusion totally pasted the wrong link, and as Nathan points out, completely meant entityResource.
If you are now looping through the properties and finding a value in the format:
umb://document/abc12d3ef4567890e1f2345g678hi901
then this is the new Umbraco UDI a unique identifier for a content item (to eventually replace integer ids everywhere), my guess is the property that has this value is a Content Picker, this property type, allows editors to pick other content nodes that are related to the current content item... so you'd need to make a further request to retreive this picked objects details if you need to display any of it's details in your listview.
regards
Marc
Yes, it's one of those xxxx2 content pickers. Actually, there are quite a few properties I need to access values for, with .config.idType = "udi"
I have to admit to being a bit stuck at the moment. I can't seem to find a BackOffice Resource, Service or Helper that addresses this, and am not sure where to go from here.
Sorry my first reply didn't expand on anything, this one will be better...
To fetch a single content item by id/udi, you need the contentResource. You can inject that into your controller, and access its methods, like so:
Full docs live here => https://our.umbraco.com/apidocs/ui/#/api/umbraco.resources.contentResource
Ah-Hah!
If property.config.idType === "uid" then use property.value as an ID to fetch the associated content.
That was the missing piece of the puzzle for me, and now I have it working - although I doubt debugged.
Thanks to all for the help.
is working on a reply...