I've been trying to add a data type (textfield) to a custom section in my Umbraco CMS. Basically I want to add a textfield and be able to save the text and retreieve it when I load the custom page the next time.
So far I've added the textfield by doing:
DataTypeDefinition d = DataTypeDefinition.GetDataTypeDefinition(-88); // -88 is the textfield txtField = (umbraco.editorControls.textfield.TextFieldEditor)d.DataType.DataEditor; placeHolder.Controls.Add(txtField);
That works fine, now I just need to be able to save the text I enter to it and retreive it when I refresh the page.
The reason why I tried to use the Umbraco datatype is because I thought the saving/retreing process would be easier. I'll take a look, but my main concern is how the data is saved into the Umbraco DB.
If you're building a custom section you need to determine how to save the data. You can do it in a custom table or an XML file. It won't be stored inside Umbraco tables even if you're using datatypes.
Well your custom section won't work with courier since it's all custom stuff. Courier can't possibly know how to import and export that. If you want to support your custom section in Courier you'll need to write a lot of stuff yourself (I haven't tried it yet). I always store my custom section data in custom tables because it usually involve a lot of relations. Here is a manual on how to use Courier with custom tabels: http://nightly.umbraco.org/UmbracoCourier/Developer%20Docs.pdf.
Adding data type to custom section in CMS
Hi
I've been trying to add a data type (textfield) to a custom section in my Umbraco CMS. Basically I want to add a textfield and be able to save the text and retreieve it when I load the custom page the next time.
So far I've added the textfield by doing:
DataTypeDefinition d = DataTypeDefinition.GetDataTypeDefinition(-88); // -88 is the textfield
txtField = (umbraco.editorControls.textfield.TextFieldEditor)d.DataType.DataEditor;
placeHolder.Controls.Add(txtField);
That works fine, now I just need to be able to save the text I enter to it and retreive it when I refresh the page.
Any help would be much appreciated!
Thanks!
You can find more examples in this topic: http://our.umbraco.org/forum/developers/extending-umbraco/6863-Datatype-on-normal-page-or-UserControl.
Also have a look at this wiki: http://our.umbraco.org/wiki/reference/code-snippets/use-mntp-on-a-usercontrol. It's an example with the Multi Node Tree Picker, but it also shows how you can save for example.
But why would you want a textbox datatype in your custom section? You can also just add a normal webcontrol textbox like in this example: http://our.umbraco.org/wiki/reference/umbraco-best-practices/standard-ui-controls/umbracouicontrols-page-samples.
Jeroen
Hey Jeroen
The reason why I tried to use the Umbraco datatype is because I thought the saving/retreing process would be easier. I'll take a look, but my main concern is how the data is saved into the Umbraco DB.
If you're building a custom section you need to determine how to save the data. You can do it in a custom table or an XML file. It won't be stored inside Umbraco tables even if you're using datatypes.
Jeroen
Oh I see. Do you know how most packages do it, e.g. Courier? Do they just store it in XML?
Well your custom section won't work with courier since it's all custom stuff. Courier can't possibly know how to import and export that. If you want to support your custom section in Courier you'll need to write a lot of stuff yourself (I haven't tried it yet). I always store my custom section data in custom tables because it usually involve a lot of relations. Here is a manual on how to use Courier with custom tabels: http://nightly.umbraco.org/UmbracoCourier/Developer%20Docs.pdf.
Jeroen
Ah, I didn't mean supporting my custom section in Courier, I was just wondering how some packages for Umbraco store their data.
Thanks
Well if there's lot's of data the best way is to store it in XML. DAMP and Embedded Content do this and it works very well.
Jeroen
is working on a reply...