Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Before my first post, will just say I'm just starting out with Umbraco and loving it!Thanks for a great product and great documentation/support.
I have a particular document type which some of its properties' data already exist in another system. So the idea is when the CMS user creates the page, they may choose to import some content from the other system by entering an ID, clicking a button, then the CMS will let them choose which data to copy in, before updating the properties' values in the CMS.
So far I have created a new datatype which stores the identifier entered (which is just a string) and renders using a user control implementing IUsercontrolDataEditor. I added a button to the user control and made the API call to the other system to load in the existing data and let the user choose which values to import. Now comes my problem - I have to somehow copy the values into the CMS.
My ideal solution is to find the various editor fields in the cms (all are textstrings) and update the value in them, so that the new values can be checked in their actual fields before the user clicks Save. Is this possible (to update values of OTHER properties from within one property's editor) and if so, how? If not, I was going to find the current node's ID so I can load it up and update the values programatically, but I can't find out how to get the current node ID either! Perhaps i'm going about this completely wrong and should be extending the main CMS editor 'page' instead of a custom datatype.
Thanks for your help,
I think your approach should work fine. you've implemented the right interface, and the framework will take care of calling the Save() method on your custom datatype. On Save(), make sure to format your data in the form which umbraco can accept to save the data to the database (int, varchar, ...).
If you need to check or change other properties' data, you could do this by subscribing to the Save event on your document (Find more info on event handling in the wiki section) and if required, change the data of the other properties. Properties are exposed throuhg their alias, so
will get you the value of a specific property on the current edited document.
If using the event approach, you'll have total control over what document is being edited (comes as an argument on the event)
Hope this helps.
I've looked through a few of my recent Umbraco installs and the HTML INPUT Id's for each property are "ctl00_body_", then the property alias. So it should be easy to populate those textfields via your custom data-type.
The only gotcha would be if the control ID prefix changes ... not sure what the circumstances are for that to happen ... but I wouldn't rule it out. So then you might have to try to guess it - using the ClientId of your custom data-type (stripping out the alias suffix, if that makes sense?)
Good luck with this, let me know how it goes ... it could be very promising for future custom data-types.
PS. It's good to have another local (Bristol-based) developer on the forums!
Thanks, this is what I ended up doing and it works a treat. Unfortunately the ClientID of my usercontrol doesn't match that of the builtin textstring fields - it has another level of nesting, so I have hardcoded it for now. Hopefully the IDs could only change on upgrading the CMS in which case we would notice it and update the code.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted