Copied to clipboard

Flag this post as spam?

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


  • Troska 21 posts 41 karma points
    Jan 16, 2012 @ 12:36
    Troska
    0

    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!

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jan 16, 2012 @ 12:52
    Jeroen Breuer
    0

    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

  • Troska 21 posts 41 karma points
    Jan 16, 2012 @ 12:56
    Troska
    0

    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.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jan 16, 2012 @ 13:02
    Jeroen Breuer
    0

    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

  • Troska 21 posts 41 karma points
    Jan 16, 2012 @ 15:27
    Troska
    0

    Oh I see. Do you know how most packages do it, e.g. Courier? Do they just store it in XML? 

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jan 16, 2012 @ 15:40
    Jeroen Breuer
    0

    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

  • Troska 21 posts 41 karma points
    Jan 16, 2012 @ 16:20
    Troska
    0

    Ah, I didn't mean supporting my custom section in Courier, I was just wondering how some packages for Umbraco store their data.

    Thanks

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jan 16, 2012 @ 16:23
    Jeroen Breuer
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft