Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • lj 81 posts 425 karma points
    Feb 27, 2014 @ 10:55
    lj
    0

    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

  • Matthieu Nelmes 102 posts 385 karma points
    Sep 03, 2015 @ 15:05
    Matthieu Nelmes
    0

    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?

  • Mark Bowser 273 posts 860 karma points c-trib
    Sep 03, 2015 @ 16:51
    Mark Bowser
    0

    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
    
  • Søren Kottal 713 posts 4571 karma points MVP 6x c-trib
    Sep 04, 2015 @ 09:51
    Søren Kottal
    0

    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.

  • Matthieu Nelmes 102 posts 385 karma points
    Sep 04, 2015 @ 10:01
    Matthieu Nelmes
    0

    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

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Sep 04, 2015 @ 10:06
    Alex Skrypnyk
    0

    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

  • Matthieu Nelmes 102 posts 385 karma points
    Sep 04, 2015 @ 10:09
    Matthieu Nelmes
    0

    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

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Sep 04, 2015 @ 15:19
    Alex Skrypnyk
    0

    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?

  • Matthieu Nelmes 102 posts 385 karma points
    Sep 04, 2015 @ 15:26
    Matthieu Nelmes
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft