Thanks Tom, but that just gives me access to the current browser location. The issue is that my Umbraco instance has multiple root nodes mapped to different domains. The domain used to log into Umbraco is not necessarily the domain on the node I'm trying edit in the Property Editor.
Hello Paul,
I don't think Umbraco ships with any AngularJS service that would let you know what Hostnames/Domains is available.
I would recommend creating a C# Web API controller that your AngularJS can do a $http.get() to and return some JSON of the hostnames that this node has available.
You would need to create an UmbracoAuthorisedApiController to ensure its not publicly available and only available in the backoffice of Umbraco and then simply use the Umbraco APIs to fetch the domain/hosts of that node id.
Hope that gives you a starting point or an idea on how I would go about tackling the problem.
A bit of a facepalm moment, but I found that I didn't have any hostnames in my test umbraco instance! So.... that's why editorState.current.urls didn't have any host names.
So now I can get at the urls in the controller without any server side code.
There is one exception. If the current url that umbraco is being accessed is the same as one of the hostnames attached to a node, then the hostname is not returned by editorState.current.urls.
e.g. if you bind mysite.local to a node and have a Property Editor on that node, then editorState.current.urls will return /node-name not mysite.local/node-name.
That's a simple one to fix though using $location rather than using the server side code.
Retrieve Hostname in Angular for Property Editor
I'm trying to create a property editor that will retrieve the full URL of the current page being edited in the backend.
I've managed to access part of the Url but it's missing the hostname.
Any ideas how I can get the full url including protocol and hostname in Angular?
would you not use $location.absUrl(); see https://docs.angularjs.org/api/ng/service/$location
t
Thanks Tom, but that just gives me access to the current browser location. The issue is that my Umbraco instance has multiple root nodes mapped to different domains. The domain used to log into Umbraco is not necessarily the domain on the node I'm trying edit in the Property Editor.
Hello Paul,
I don't think Umbraco ships with any AngularJS service that would let you know what Hostnames/Domains is available.
I would recommend creating a C# Web API controller that your AngularJS can do a $
http.get()
to and return some JSON of the hostnames that this node has available.You would need to create an
UmbracoAuthorisedApiController
to ensure its not publicly available and only available in the backoffice of Umbraco and then simply use the Umbraco APIs to fetch the domain/hosts of that node id.Hope that gives you a starting point or an idea on how I would go about tackling the problem.
Cheers,
Warren
Comment author was deleted
You should be able to fetch the current node by injecting the editor state http://umbraco.github.io/Belle/#/api/umbraco.services.editorState, it might be that it also exposes the url but not 100% (if not you'll need to fetch the url based on the id)
Comment author was deleted
If the editorstate doesn't include the url you can fetch it with the ContentResource ( getNiceUrl(id) ) http://umbraco.github.io/Belle/#/api/umbraco.resources.contentResource
Comment author was deleted
For the hostname you'll probably need to write some code since I don't see a hostnameResource or Service in the docs
Comment author was deleted
Some code to get you started, https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/AssignDomain2.aspx.cs
Cheers guys I'll use that as a starting point and let you know how I get on.
Thanks
A bit of a facepalm moment, but I found that I didn't have any hostnames in my test umbraco instance! So.... that's why editorState.current.urls didn't have any host names.
So now I can get at the urls in the controller without any server side code.
There is one exception. If the current url that umbraco is being accessed is the same as one of the hostnames attached to a node, then the hostname is not returned by editorState.current.urls.
e.g. if you bind mysite.local to a node and have a Property Editor on that node, then editorState.current.urls will return /node-name not mysite.local/node-name.
That's a simple one to fix though using $location rather than using the server side code.
is working on a reply...