contentResource.getById(editorState.id).then(function(node){
var theTabYouWant = 0;
var thePropertyYouWant = 3;
var theValueYouWant = node.tabs[theTabYouWant].properties[thePropertyYouWant].value;
});
But you need to know the structure of the data. But you can use Chromes debugger to visualize the data.
I created simple helper function for handling it. It is using underscore to filter and retrieve proper value for desired property by alias.
$scope.getPropertyValueByAlias = function (myAlias) {
return _.findWhere(_.filter(editorState.current.tabs, function(tab) {
return _.some(tab.properties, { alias: myAlias });
})[0].properties, {
alias: myAlias // It could be any else property you want
}).value;
};
Thanks for sharing this it saved me a great headache. I would have thought there would be an easier way to access this data without first having to know the structure.
How get properties of current node in custom propertie editor?
Hi,
I have create my first propertie editor in Umbraco 7 and with this code in my myPropertieEditor.controller.js I get the name and id of current node:
But Idon't know how I get the other custom properties of current node. Have everyone an idea?
Best regards
Sören
maybe you can use the contentResource http://umbraco.github.io/Belle/#/api/umbraco.resources.contentResource
Hi Tom,
thank you. With this code I can get the name or id (node.name, node.id). But do you know how I can get the value of a specific propertie of this node?
I think you can do something like this:
But you need to know the structure of the data. But you can use Chromes debugger to visualize the data.
Thank you very much for this excellent description ! It works great :-)
Sören
Glad I could help :) I'm not sure its the best way to do it - but it works!
This is suboptimal as the data can change at the whim of a designer.
Yeah if the user change the tab-name the code will break.
It would be great it there where a method like:
But wait (he says so many months later;), there is!
from http://umbraco.github.io/Belle/#/api/umbraco.services.contentEditingHelper ::
contentEditingHelper (service in module umbraco.services ) getAllProps()
Hiya,
Sorry for joining late but once you have:
how do you retrieve the property you want by its alias??
Regards, L
Hello,
I created simple helper function for handling it. It is using underscore to filter and retrieve proper value for desired property by alias.
Hope that it will be helpful for anyone else.
Thanks for sharing this it saved me a great headache. I would have thought there would be an easier way to access this data without first having to know the structure.
Is this still the easiest way to get properties from a node using the property alias?
Thanks, Simon
is working on a reply...