I've built a custom component, it's being used on the dashboard.My site exists on several different languages, it's setup like this:mysite.com - englishmysite.se - swedishmysite.dk - danishI have a page named mypage that exists in three different languages, the url is different depending on language, examples:mysite.com/my-pagemysite.se/min-sidamysite.dk/some-danish-here
In my component I'm using the contentselector, "epi-cms/widget/ContentSelector".Now, say that Im on mysite.com in edit mode, language is english, when I open the ContentSelector(showAllLanguages is set to true) I want the editor to be able to select a specific language of a page, let's say the danish version.So, my goal is that when the editor opens the ContentSelector, he/she would see that MyPage exists in three different languages and be able to choose the danish version, I would then like to retrieve the absolute url to it, in my example that would be mysite.dk/some-danish-here.However, when I open up the ContentSelector, I can only see the english version of the page(I guess because it's context based and my "UI-language" currently is English.So, my question is: is it possible to pass in a language to the ContentSelector? Or do I need to switch context somehow in edit mode?I guess it's not possible to pass in a language to the ContentSelector, so my next question is, given a contentreference, can I somehow retrieve all different languages versions of a page with DOJO? Im guessing that I should use either the "epi.cms.contentdata" or "epi.cms.contentversion" store somehow?Pseudo code:var myContentReference = 1337;var result = someStore.getAllLanguageVersionsOfPage(myContentReference);// result contains all different versions together with all different urls to said page.
No unfortunately there is no easy API call to get all language versions of a page. The closest to what it sounds like you want to do is probably to use the content data store ("epi.cms.contentdata").
When getting a content from that store, the object returned contains a property called existingLanguageBranches. That property is an array that contains some information regarding each language which includes a version specific contentLink. Perhaps that is something you can use to build the urls to the different pages.
Yeah, I've already tried using the contentdata-store and the existingLanguageBranches array. The problem is that I can only get the urlsegment there, for example "/en/", I can't get the different hostnames...right now im using the SiteDefintitionRepository to get all available hostnames.The problem is when Im opening the contentselector, the context of the selector will be "en" for example if im on mysite.com. Ideally I would like to be able to pass in "sv" or something similar to the contentselector and thus get the contentselector to show me all pages existing in swedish... :)The component im building is a redirect component where I want the editor to be able to select the target site using the contentselector. This works fine if the site only has one host specified, but I run into some problems if more hosts exists because I want the editor to be able to create a redirect from mysite.com to mysite.se for example...that's why I need to be able to fetch all different language versions so the editor can select the appropiate url...
OK, I think I understand now.
It sounds like it would be best for you to create a custom store so that you can resolve the URL's on the server using IUrlResolver. Send in a contentLink and get all existing language URLs back.
Hmmm...that sounds interesting! Do you have a link to the documentation regarding custom stores? I know I had that thought before but I couldn't find any pointers of how to implement a custom store when I looked in the documentation... https://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/User-interface/Store-architecture/Thank you for your help, really appreciate it.Or custom store...I could just build an api endpoint I guess... :)
Hmm, we seem to be missing some documentation in this area. That must be the first time that happened ;)
But I found this old documentation. It's old but it should still work: http://world.episerver.com/documentation/items/developers-guide/episerver-framework/7/user-interface/setting-up-a-rest-data-store/
The only thing missing is the registration of the module initialization. Grzegorz mentions in this thread on how to do that: https://world.episerver.com/forum/developer-forum/-Episerver-75-CMS/Thread-Container/2016/3/episerver-reststore-not-initializing/
I'll report a documentation bug on it to make sure we provide a more up to date version of how to set up a rest store.
Haha yeah, definetly a first ;)Thank you so much, this will finally allow me to release my component to the public...expect a blog post in a week or two.. :D