Firstly, I think I need to ask is your API for front end use or back end use? The reason I ask is that if it is front end you really shouldn't be using the ContentService to retrieve content. This makes calls, as far as I understand it, to the database where as using Umbraco helpers uses the published cache.
However, in answer to your actual question I believe you would either need to create a custom model to return then you could put all the information in one call, else you will need to make a new call to retrieve the content type for each unique content type you want to know about.
I think you need to explain a bit more about what you are trying to achieve.
What is args.node ? If that is just a property on an object then you can easily create your own model that has said property on it, plus additional properties such as the content type etc.
How to get the icon of a node using the api
Hi,
I have a api which returns the result of following method:
I get the result as json ( below is of one node in the list ):
But the icon is in the
ContentType
object. In VS2015 I see this but it does not return this object it only returns the id of the ContentType.Do I need to call this in a sepetared function inside my controller or... ?
/Michaël
Hi Michael,
Firstly, I think I need to ask is your API for front end use or back end use? The reason I ask is that if it is front end you really shouldn't be using the ContentService to retrieve content. This makes calls, as far as I understand it, to the database where as using Umbraco helpers uses the published cache.
However, in answer to your actual question I believe you would either need to create a custom model to return then you could put all the information in one call, else you will need to make a new call to retrieve the content type for each unique content type you want to know about.
Thanks,
Nik
What Nik said. If you have only the ContentType id, you can call the contentTypeService to get all information about your content type.
Hi,
I am building a custom plugin which is a new tab in the content section so its not for the frontend.
A custom model will be hard I think because I will be using services where the args.node is needed, which is the
IContent
model or am I wrong?/Michaël
Hi Michael,
I think you need to explain a bit more about what you are trying to achieve. What is args.node ? If that is just a property on an object then you can easily create your own model that has said property on it, plus additional properties such as the content type etc.
Nik
Ok I have solved it like the suggestion of creating a new ViewModel where I put my
IContent
andIContentType
objects.Thanks
/Michaël
Im fully with you creating models tailored to your purpose when subsetting or extending information but fpr your purpose does contentresource not do want you want without additional coding? See this https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/53002-How-get-properties-of-current-node-in-custom-propertie-editor the angular resource contains various methods you might be able to call.
Yes it can also but then it will call the database again and if I have 200 nodes to evaluate that will be hard for the database.
In my api I have already all the intel so I just need to merge it into my viewmodel and sent it back.
/Michaël
is working on a reply...