Custom Property Editor - Get value of MultiNodeTreePicker
Hi All,
I'm trying to create a custom property editor that will return all child documents of a given parent for a given document type. I've found examples of how to setup something similar here: Umbraco v7 XPathDropdownList aka Docr
My problem has to be read from a separate control. To this end I set up my custom control to require the document type alias and the alias of the control that holds the document to be used as parent. I've found that if this control is of type MultiNodeTreePicker then I can't read it's value. Textstring and number fields, however, work fine.
Can anyone see what I'm doing wrong here?
Thanks
Ver
Controller file:
angular.module("umbraco")
.controller("cmsHoR.DocrController",
function ($scope, docrResource, notificationsService, editorState) {
//first we retrieve all children docs from requested node
docrResource.getChildren($scope.model.config.documentTypeAlias,
editorState.current,
$scope.model.config.fieldToRead).then(function (response) {
$scope.documents = response.data;
}, function () {
notificationsService.error("Error", "Error loading child documents");
});
});
Resources File
angular.module('umbraco.resources').factory('docrResource', function ($q, $http) {
return {
getChildren: function (documentTypeAlias, currentState, fieldToRead) {
if (currentState != undefined && documentTypeAlias != "") {
//Urggghh.. currently hardcoding path to property
var rootNode = currentState.tabs[0].properties[7];
var url = "backoffice/cmsHoR/DocrApi/GetChildDocuments";
url += "?documentAlias=" + documentTypeAlias;
url += "&rootNode=" + rootNode.value;
return request = $http.get(url);
}
return null;
}
};
});
View file:
<div ng-controller="cmsHoR.DocrController">
<select
name="DocrDropdownList"
class="umb-editor umb-dropdown"
ng-model="model.value"
ng-options="d.Id as d.Name for d in documents" />
</div>
Manifest
{
propertyEditors:
[
{
alias: "cmsHoR.Docr",
name: "cmsHoR Document Selection",
editor:
{
view: "~/App_Plugins/Docr/Docr.html"
},
prevalues:
{
fields:
[
{
label: "Document Type Alias",
description: "Type the document alias to select",
key: "documentTypeAlias",
view: "textstring"
},
{
label: "Alias of field to use as parent",
description: "Type the alias of a content picker field to be used as the parent document",
key: "fieldToRead",
view: "textstring"
}
]
}
}
],
javascript:
[
"~/App_Plugins/Docr/Docr.controller.js",
"~/App_Plugins/Docr/Docr.resources.js",
]
}
Chrome debug showing contents of MultiNodeTreePicker via editorState.current
Chrome debug showing contents of text field via editorState.current
On further investigation I found that this only happens if I try to give a maximum value to the picker. Without it, the value is correctly shown in editorState.current.tabs[x].properties[y].
BTW, I found that using the contentEditingHelper provides 'easier' access to the editorState properties:
This gives me a flat array of objects which I can then use to match according to the alias I require. Much simpler for me than trying to recurse through all entries or much worse, hardcoding the path.
Regards
** edited to correct brackets as per Kristian's post below.
Further update, I've worked around my problem by sitting using a nuPicker XML Dropdownlist as the separate control and setting it to store data as CSV. This control works correctly with editorState.
My last issue is how to determine when a user selects a different value in the dropdown as I then need to change the data in my custom control accordingly.
Hmm. Using the nuPicker solved my original MNTP issue but gave me another. I've found that the nuPicker XML Dropdown does not populate itself upon creating a document. I need to save the document first, which is a pain since I really need the MNTP/nuPicker dropdown to be mandatory.
This will find a node with a given ID (can of course also use the "current" suggestions above), and loops the properties and looks for an alias of a given string (here: "image"). This way you can look for a property of a given name. This looks/feels a little messy, but it works and I was under a bit of pressure while making it :D
Custom Property Editor - Get value of MultiNodeTreePicker
Hi All,
I'm trying to create a custom property editor that will return all child documents of a given parent for a given document type. I've found examples of how to setup something similar here: Umbraco v7 XPathDropdownList aka Docr
My problem has to be read from a separate control. To this end I set up my custom control to require the document type alias and the alias of the control that holds the document to be used as parent. I've found that if this control is of type MultiNodeTreePicker then I can't read it's value. Textstring and number fields, however, work fine.
Can anyone see what I'm doing wrong here?
Thanks
Ver
Controller file:
Resources File
View file:
Manifest
Chrome debug showing contents of MultiNodeTreePicker via editorState.current
Chrome debug showing contents of text field via editorState.current
Document showing that Link To Sitting has a value
Hi All,
On further investigation I found that this only happens if I try to give a maximum value to the picker. Without it, the value is correctly shown in editorState.current.tabs[x].properties[y].
BTW, I found that using the contentEditingHelper provides 'easier' access to the editorState properties:
This gives me a flat array of objects which I can then use to match according to the alias I require. Much simpler for me than trying to recurse through all entries or much worse, hardcoding the path.
Regards
** edited to correct brackets as per Kristian's post below.
Further update, I've worked around my problem by sitting using a nuPicker XML Dropdownlist as the separate control and setting it to store data as CSV. This control works correctly with editorState.
My last issue is how to determine when a user selects a different value in the dropdown as I then need to change the data in my custom control accordingly.
Ver
Just a side note to anyone landing here for the same reason as me.
The syntax to get the properties is:
not square brackets.
Thats all.
Hmm. Using the nuPicker solved my original MNTP issue but gave me another. I've found that the nuPicker XML Dropdown does not populate itself upon creating a document. I need to save the document first, which is a pain since I really need the MNTP/nuPicker dropdown to be mandatory.
I'll raise an issue against umbraco for the MNTP.
Ver
Hi,
I know this is an old post but when using
what is the quickest way to retrieve the property you want with the alias? For example I want to retrieve the property with alias newsTitle
Regards, L
Hello, hi, g'day
A little late to the party, maybe, but I thought I'd share my findings, having dealt with a similar issue:
This will find a node with a given ID (can of course also use the "current" suggestions above), and loops the properties and looks for an alias of a given string (here: "image"). This way you can look for a property of a given name. This looks/feels a little messy, but it works and I was under a bit of pressure while making it :D
Hope this helps someone
is working on a reply...