Is there anyway to get a value from an unpublished node?
Here's my code :
public JsonResult<String> GetData()
{
var id = HttpContext.Current.Request.QueryString["id"];
dynamic properties = Umbraco.Content(Convert.ToInt32(id));
return Json(properties.Data);
}
If I go to the BackOffice and chage the value of "Data" and just Save It, my method always return the last published version instead of my new saved, but unpublished one.
Keep in mind if you use the ContentService you are talking directly to the database. This approach might not scale if your site receives a lot of visitors.
I'm the new to Umbraco and I'm struggling to get the unpublished contents. Kindly guide me to get the unpublished contents.
I have created a document type article and article items as mentioned in Our Umbraco tutorial.
In content section I have created a five number of article items as a blog and unpublished two of them.
I'm getting three published article items in the site. Now I want to get the unpublished contents instead of published one.
How I can do this???
Get unpublished content?
Hi!
Is there anyway to get a value from an unpublished node?
Here's my code :
If I go to the BackOffice and chage the value of "Data" and just Save It, my method always return the last published version instead of my new saved, but unpublished one.
Thanks!
Would this work? I've used this to query for reviews tagged to unpublished locations, worked great for me.
https://our.umbraco.com/forum/developers/api-questions/49595-Query-unpublished-nodes-by-property-value
There's a check in the API to see if something is published, you could just filter for the opposite.
I tried it, but when I use the getValue method from the IContent returned by the query, it always return me null.
That's said, I don't think it will see the difference between my published value and my saved value.
I finally get this to work with the API. Yeah!
Keep in mind if you use the
ContentService
you are talking directly to the database. This approach might not scale if your site receives a lot of visitors.You're right! Is there a more performant way to do this?
Hi Marc-André,
I'm the new to Umbraco and I'm struggling to get the unpublished contents. Kindly guide me to get the unpublished contents.
I have created a document type article and article items as mentioned in Our Umbraco tutorial. In content section I have created a five number of article items as a blog and unpublished two of them. I'm getting three published article items in the site. Now I want to get the unpublished contents instead of published one. How I can do this???
Kindly guide to do this.
For others who may come across this you can do the following:
_service is ServiceContext _services which can be injected into your controller if you are using a controller.
You can get descendants or children. This is not optimal at all so use it wisely.
is working on a reply...