Updating content property in the database without creating a new version and an audit log
Hi all,
I'd like to update the value of my content's property in the database (and in the cache as well so that Umbraco knows about my change) without creating a new audit trail and a new version. So I want to update the most recent version of my content, without creating any new version of it.
I found that the ContentService.Save() method does the actual update but it also creates a new version along with the audit log.
I'm not sure that what you're asking is possible - Why do you want to create content, which does not have a new version? If it's not versioned you will not be able to rollback to a another version if you need to display a temporary text or something and then need to rollback to the first version after a period of time for instance.
Just trying to figure out your reason for wanting to achieve this and understand you scenario.
My scenario is this: I have a content, which has 1 field (datatype of a label), that is only displayed in the backoffice. It is a counter: how many times my content "got opened" in the frontend. So whenever someone opens my content, I'm also incrementing this counter. Now this counter incrementing creates a new version which I don't want, it's just a visual information for the backoffice admin.
Or shall I create a new table for this, and incrementing the counter there? If the latter is the situation to go with, how can I display this additional information from a separate table in the "content" section in the backoffice? Can I hook somehow into the displaying process of the content? I could call a custom Web Api controller to retrieve my data.
Ok - I don't suppose this is something that could be checked in Google Analytics instead? Sounds like it's very specific for a certain type of content? There is a nice Google Analytics pakcage for Umbraco 7, which makes creates a new section where editors can access loads of GA data. Don't know if that's perhaps an option?
But if Google Analytics is not an option then I think perhaps creating a custom table and provide the information using a dashboard might be the way to go. Don't think you can stop Umbraco from creating versions each time something is saved using the public API's.
I'm using version 7.2.1. GA is not an option, I also have another scenario, where a user can vote on a specific content whether she likes it or not (this info is again only for the backoffice admin).
That is not something that could be done by GA. However I'm still trying to use the built in "contents" b/c they get cached on the frontend.
If somehow I could hook into the displaying process in the backoffice to retrieve my data from the database and display the related info (in the content section along with the other data coming from the umbraco tables). Maybe using a "custom property editor"? Not a nice solution, but there I have an angular controller and a template. Only thing I need is the "Id" of the related content.
Ok - I think what you need is a custom table, which you can then expose data from in a dashboard instead.
I have not figured out 100% how custom dashboards work in Umbraco 7 yet but in the /config/Dashboards.config you can setup dashboard in the different sections of Umbraco. So you can add a specific administrator Dashboard in your "Content" section if you would like to.
I think that the intention is that everything that is a plugin should go in the /App_Plugins/ folder - So not just custom property editors but also dashboards etc.
And then you can use angularjs to display the data - The AngularWorkbook is a nice ressource for this https://github.com/umbraco/AngularWorkbook - However it's displaying how to create a custom property editor but some of the conepts should be the same for creating a custom dashboard I think.
Updating content property in the database without creating a new version and an audit log
Hi all,
I'd like to update the value of my content's property in the database (and in the cache as well so that Umbraco knows about my change) without creating a new audit trail and a new version. So I want to update the most recent version of my content, without creating any new version of it.
I found that the ContentService.Save() method does the actual update but it also creates a new version along with the audit log.
Is there any API to achieve this?
cheers,
Peter
Hi Peter and welcome to our :)
I'm not sure that what you're asking is possible - Why do you want to create content, which does not have a new version? If it's not versioned you will not be able to rollback to a another version if you need to display a temporary text or something and then need to rollback to the first version after a period of time for instance.
Just trying to figure out your reason for wanting to achieve this and understand you scenario.
/Jan
Hi Jan!
Thanks for your feedback.
My scenario is this: I have a content, which has 1 field (datatype of a label), that is only displayed in the backoffice. It is a counter: how many times my content "got opened" in the frontend. So whenever someone opens my content, I'm also incrementing this counter. Now this counter incrementing creates a new version which I don't want, it's just a visual information for the backoffice admin.
Or shall I create a new table for this, and incrementing the counter there? If the latter is the situation to go with, how can I display this additional information from a separate table in the "content" section in the backoffice? Can I hook somehow into the displaying process of the content? I could call a custom Web Api controller to retrieve my data.
Hi Peter
Ok - I don't suppose this is something that could be checked in Google Analytics instead? Sounds like it's very specific for a certain type of content? There is a nice Google Analytics pakcage for Umbraco 7, which makes creates a new section where editors can access loads of GA data. Don't know if that's perhaps an option?
But if Google Analytics is not an option then I think perhaps creating a custom table and provide the information using a dashboard might be the way to go. Don't think you can stop Umbraco from creating versions each time something is saved using the public API's.
What exact version of Umbraco are you using?
/Jan
I'm using version 7.2.1. GA is not an option, I also have another scenario, where a user can vote on a specific content whether she likes it or not (this info is again only for the backoffice admin).
That is not something that could be done by GA. However I'm still trying to use the built in "contents" b/c they get cached on the frontend.
If somehow I could hook into the displaying process in the backoffice to retrieve my data from the database and display the related info (in the content section along with the other data coming from the umbraco tables). Maybe using a "custom property editor"? Not a nice solution, but there I have an angular controller and a template. Only thing I need is the "Id" of the related content.
Hi Peter
Ok - I think what you need is a custom table, which you can then expose data from in a dashboard instead.
I have not figured out 100% how custom dashboards work in Umbraco 7 yet but in the /config/Dashboards.config you can setup dashboard in the different sections of Umbraco. So you can add a specific administrator Dashboard in your "Content" section if you would like to.
I think that the intention is that everything that is a plugin should go in the /App_Plugins/ folder - So not just custom property editors but also dashboards etc.
And then you can use angularjs to display the data - The AngularWorkbook is a nice ressource for this https://github.com/umbraco/AngularWorkbook - However it's displaying how to create a custom property editor but some of the conepts should be the same for creating a custom dashboard I think.
I hope this makes any sense :)
/Jan
Thanks Jan, custom table saved me!
Hi Peter
You're welcome, happy that I could help :)
Happy coding!
/Jan
is working on a reply...