I am using umbraco 7 and started working with property editors with angularjs. There is lots of good examples out there even using custom data http://www.nibble.be/?p=330. What I am struggling to find is an example of actually manipulating/saving custom data to custom database table. Alll the examples once user saves, automatically save the data to umbraco table cmsContentXml but I actually wont to deal with that data myself.
Has anyone found a good example of this or can point me in the right direction for resources.
The data will actually end up in the cmsPropertyData table. I believe that on publish, the newest version of the published node gets cached into the cmsContentXml table, but the data's real home is in the cmsPropertyData table.
Not sure how to get the data to save to a separate table. I'll be following out of curiosity :)
If you are unable to figure this out and just need to get at the data, this is a query I threw together to get the most recent data for a specific node. Hope this helps.
SELECT TOP 1000 n.id AS nodeId
,n.[text]
,n.[path]
,pt.[alias]
,pd.dataNtext
,cv.VersionDate
FROM cmsPropertyData pd
INNER JOIN cmsPropertyType pt
ON pt.id = pd.propertytypeid
INNER JOIN cmsContentVersion cv
ON pd.versionId = cv.VersionId
INNER JOIN (SELECT cvi.ContentId, MAX(cvi.VersionDate) AS VersionDate -- get the newest version
FROM cmsContentVersion cvi
GROUP BY cvi.ContentId) cv_max
ON cv_max.ContentId = pd.contentNodeId AND cv_max.VersionDate = cv.VersionDate
INNER JOIN umbracoNode n
ON n.id = pd.contentNodeId
WHERE n.id = 1284
ORDER BY contentNodeId
I did find this very useful tutorial - although it only really covers saving data from an end-user perspective ie. Visitor comments. It does deal with saving to custom tables ala PetaPoco:
So data will be stored in Umbraco and your custom table ?
I mean you will subscribe to save event, on this stage data is saving to Umbraco and you will save it to your custom data source.
Am I wrong?
In my instance it will be a mixture of both. But I don't want to hijack this thread too much. But I managed to answer my own question with a combination of both of our replies.
In my instance. When an item is saved within the CMS, I want to save the original Umbraco content as per, and then save additional data from custom property editors to a custom table in my database.
property editor saving custom data
Hi,
I am using umbraco 7 and started working with property editors with angularjs. There is lots of good examples out there even using custom data http://www.nibble.be/?p=330. What I am struggling to find is an example of actually manipulating/saving custom data to custom database table. Alll the examples once user saves, automatically save the data to umbraco table cmsContentXml but I actually wont to deal with that data myself.
Has anyone found a good example of this or can point me in the right direction for resources.
Thanks
LJ
I'm also researching this for an upcoming project. This post came out top on Google search results.
Did you ever find anything useful and care to share?
The data will actually end up in the
cmsPropertyData
table. I believe that on publish, the newest version of the published node gets cached into thecmsContentXml
table, but the data's real home is in thecmsPropertyData
table.Not sure how to get the data to save to a separate table. I'll be following out of curiosity :)
If you are unable to figure this out and just need to get at the data, this is a query I threw together to get the most recent data for a specific node. Hope this helps.
You can create an API for handling the custom data, and have an angular service on your editor call that for getting or setting values.
I did find this very useful tutorial - although it only really covers saving data from an end-user perspective ie. Visitor comments. It does deal with saving to custom tables ala PetaPoco:
https://www.youtube.com/watch?v=0PtzyrEFG7I
Thanks, Matthieu and Soren, but how we can integrate Umbraco's save and publish button with our api ??? I think this is main question of this topic.
Thanks, Alex
The topic actually asked specifically about saving to a custom table in the database.
If you want to integrate with the Save/Publish button then you'll find there are events you can hook into: https://our.umbraco.org/documentation/reference/events/contentservice-events
Matthieu,
So data will be stored in Umbraco and your custom table ? I mean you will subscribe to save event, on this stage data is saving to Umbraco and you will save it to your custom data source. Am I wrong?
In my instance it will be a mixture of both. But I don't want to hijack this thread too much. But I managed to answer my own question with a combination of both of our replies.
In my instance. When an item is saved within the CMS, I want to save the original Umbraco content as per, and then save additional data from custom property editors to a custom table in my database.
is working on a reply...