I am working with the Umbraco Rest API and I am building an Angular JS browser that loads content from Umbraco. The problem comes when I want to replace links inserted using TyneMCE.
TyneMCE insert link function in Umbraco 7.6.3, saves links to the database with the following format:
I would urge you not to use contentservice for retreiving data. The content service hits the database and bypasses the memory cache. This can be performance issue
You can pass in the guid to Umbraco.ContentQuery.TypedContent() which is avaible in a umbraco API controller. That will return the IPublishedContent item.
Or you can use Umbraco.GetIdForUdi() and that will return you the id.
By the way how are you retreving the rich text editor content ? Normally when using the API for getting published content these should be converted to actual links.
So when I try to get the html string in an hybrid application (like AngularJs for example) and try to render it, I need to replace the various UDI with an absolute path to the resource.
I see you use ApplicationContext.Services.ContentService.GetById(id) a couple of times. You should avoid this. The content service is meant for doing CRUD operations on content and bypasses the cache entirely by hitting the database. This can be a performance issue.
Better is to use :
Umbraco.TypedContent(id). This will return you the IPublishedContent instance direclty from memory.
This also has the benefit that RTE properties don't have the UDI links anymore. But contain the actual link to the item.
Do you return IPublishedContent from your API ? Because that's not serializable. Maybe you can convert it to your own model with only the properties you need.
Umbraco 7.6.3 content picker and the new data-udi
I am working with the Umbraco Rest API and I am building an Angular JS browser that loads content from Umbraco. The problem comes when I want to replace links inserted using TyneMCE.
TyneMCE insert link function in Umbraco 7.6.3, saves links to the database with the following format:
The href element is replaced by the data-udi. Umbraco Rest Api only allows to get contents by id. It is not possible to pass a route or the data-id.
My questions are:
1) Is it possible to modify TyneMCE settings in order to create a link with the id and the url of the content, in the following format:
2) How can I get the content id from the new proeprty "udi"?
3) IPublishedContent does not contain the property 'key'. How can I get the property key of a node?
Thanks in advance
Enrico
Hello Enrico Did you find a solution about this topic?
I am still trying to find a good solution, but for now I have this code
Hi Enrico,
I would urge you not to use contentservice for retreiving data. The content service hits the database and bypasses the memory cache. This can be performance issue
Dave
Hi Enrico,
You can pass in the guid to Umbraco.ContentQuery.TypedContent() which is avaible in a umbraco API controller. That will return the IPublishedContent item.
Or you can use Umbraco.GetIdForUdi() and that will return you the id.
Dave
Thanks Dave,
I will give it a try
This new Udi property is giving me headache.
Do you know if it's possible modify the way the Rich Text Editor inserts links?
Don't think that is possible. Maybe you can explain what you are trying to do ?
dave
Enrico,
By the way how are you retreving the rich text editor content ? Normally when using the API for getting published content these should be converted to actual links.
Dave
My problem is that I am using Umbraco as Rest Api and when I add images stored in Umbraco or link to Umbraco contents I need to replace them.
My scenario is:
Umbraco CMS + UmbracoApiController
In my UmbracoCMS all the pages that have a property called 'body' associated with the Richtext editor (RTE).
This is an example of what the RTE saves for the property body:
So when I try to get the html string in an hybrid application (like AngularJs for example) and try to render it, I need to replace the various UDI with an absolute path to the resource.
But how are you retreiving the content from Umbraco ?
What API are using ?
Dave
I tried with https://our.umbraco.org/documentation/implementation/Rest-Api/
But a lot of feature are missing. So I started to write my own Implementation.
This is the code of my controller
This is the code of my ExtendedContentService
This is the best solution I got at the moment. It's not perfect because scraping html strings to replace udi with absoulte path is not that easy.
Hi Enrico,
I see you use
ApplicationContext.Services.ContentService.GetById(id)
a couple of times. You should avoid this. The content service is meant for doing CRUD operations on content and bypasses the cache entirely by hitting the database. This can be a performance issue.Better is to use : Umbraco.TypedContent(id). This will return you the IPublishedContent instance direclty from memory. This also has the benefit that RTE properties don't have the UDI links anymore. But contain the actual link to the item.
Dave
Thanks Dave.
I will have a try and I let you know
Hi Dave,
I tried the Umbraco.TypedContent(id), but i got serialization issues.
I will go back using https://our.umbraco.org/documentation/implementation/Rest-Api/ and probabably extend it to implement headless CMS approach.
Hi Enrico,
Do you return IPublishedContent from your API ? Because that's not serializable. Maybe you can convert it to your own model with only the properties you need.
Dave
If you have a WYSIWYG and the link output looks like the following:
pop this at the top of the page:
then wrap the text in a HTML.Raw:
That will then output the href in the link correctly
Jon
is working on a reply...