Re-using content picker for multilingual website (Umbraco 7)
Hi everyone!
In these months my agency gave me very few hours to develop a custom data type for a multilingual website with 1 to 1 structure.
I retrieve the installed languages from an ApiController and I try to render a content picker (with umb-property and umb-editor directives) for each installed language. No problem in this step, it renders the right language occurence, but I've a problem in creating the model (in angularjs) to pass to the editor.
My ApiController returns an array of structured objects: - the language - the node (if there's a record in the relation table)
So i try to render a contentPicker for each object in the array but I cannot find the right information to pass to the contentpicker.
Could someone help me with this problem? Or can someone tell me where I can find some information about re-using content picker?
After that I wrote my language.resource.js that has a GetAll(Id) method which calls my custom umbraco Api. This Api looks for a record in the umbracoRelation table (using the RelationService) and get the related node if it exists (using the ContentService). The Api works fine, I manually put some records in the table to test the code and it correctly retieve the related nodes. My Api gives me back this structured object:
public class NodeWithLanguage
{
public IContent RelatedNode { get; set; }
public string LanguageNode { get; set; }
}
Then I wrote down my NodePickerPerLanguage.controller.js:
angular.module('umbraco')
.controller('NodePickerPerLanguage', function ($scope, $routeParams, languageResource, $http) {
languageResource.getAll($routeParams.id)
.then(function (response) {
$scope.properties = [];
var lightNode = [];
lightNode = response.data;
for (var i = 0; i < lightNode.length; i++) {
var p = {
label: lightNode[i].language,
description: lightNode[i].language,
view: 'contentpicker',
config: {
multiPicker: "0",
entityType: "Document",
startNode: {
query: "",
type: "content",
id: 1064
},
filter: ""
},
value: lightNode[i].node
}
$scope.properties.push(p);
}
return false;
})
});
and I think the problem is the json format of the node. I looked for the proper way to cast that IContent (dynamic code) to a json object for my picker, but I couldn't find anything about that (maybe I searched with the wrong keys). Or it's a problem in repeating the content picker?
Forgive me but I'm not very skilled in angularjs for now (but i'm studying hard :-P ).
I hope I've been clear enough...
Re-using content picker for multilingual website (Umbraco 7)
Hi everyone!
In these months my agency gave me very few hours to develop a custom data type for a multilingual website with 1 to 1 structure.
I retrieve the installed languages from an ApiController and I try to render a content picker (with umb-property and umb-editor directives) for each installed language.
No problem in this step, it renders the right language occurence, but I've a problem in creating the model (in angularjs) to pass to the editor.
My ApiController returns an array of structured objects:
- the language
- the node (if there's a record in the relation table)
So i try to render a contentPicker for each object in the array but I cannot find the right information to pass to the contentpicker.
Could someone help me with this problem?
Or can someone tell me where I can find some information about re-using content picker?
Thank you
S
Hi Stefano
You should use the dialogue service http://umbraco.github.io/Belle/#/api/umbraco.services.dialogService - You can see more API references here http://umbraco.github.io/Belle/#/api
And then have a look at this screencast by Per Ploug on how to use it http://www.screenr.com/kpHH
From what you're asking it sounds like what you need, let me know if I'm wrong :)
hope this helps.
/Jan
Hi Jan! Thank you for your suggestions! It's what I need but not exactly the same way I'm doing it...
I try to explain it better (with some code), so maybe you can tell me if I'm totally wrong in developing mi custom data type.
I found this article time ago http://www.wiliam.com.au/wiliam-blog/reusing-the-multi-node-tree-picker-in-a-custom-section so I reuse the code in the view to render my pickers
After that I wrote my language.resource.js that has a GetAll(Id) method which calls my custom umbraco Api. This Api looks for a record in the umbracoRelation table (using the RelationService) and get the related node if it exists (using the ContentService). The Api works fine, I manually put some records in the table to test the code and it correctly retieve the related nodes. My Api gives me back this structured object:
Then I wrote down my NodePickerPerLanguage.controller.js:
But the console always gives the error
and I think the problem is the json format of the node. I looked for the proper way to cast that IContent (dynamic code) to a json object for my picker, but I couldn't find anything about that (maybe I searched with the wrong keys). Or it's a problem in repeating the content picker?
Forgive me but I'm not very skilled in angularjs for now (but i'm studying hard :-P ). I hope I've been clear enough...
Thank you S
is working on a reply...