sitecore fields data type for xml data - sitecore

I will need to save a serialized data in a field. Can anybody please help me figure out how can i do it in sitecore.
In a sql server I can define xml field-type which is sufficient for this. But similarly I can't find anything in sitecore. Though there are two types called html & memo which are deprecated. Also want to know can I use any of these.
We are using sitecore 7.2 BTW.

You can simply store it in a multi-line text field. If you wanted to get real fancy then you could create a custom field type. I've previously even used an IFrame field type for this kind of data, since the text is blanked out to the end user (but still viewable using Raw Values) and since the underlying data is just text it worked fine.
In any case, if your field is populated automatically from an external source then you probably don't want that data editable from the content editor. Lock the field down using the security editor and using correct roles & permissions so that normal editors do not have Field Write permissions (set on the template itself, not the created items)

In Sitecore, all fields are internally kept as strings by design (except media blobs). I think the best field type to store serialized XML would be multi-line text.
Of course, you should care about all serialization and deserialization the data into that field

Related

sitecore custom text field

I'm looking for a custom text field that generates an extra text field when needed. Similar to the way a template adds new text fields.
For storage all values can be saved as one comma separated string (or pipe).
Does anyone know if this exists already? I searched the Sitecore marketplace google but haven't found what I need yet.
edit: If none exists yet I will probably make it myself with this reference: https://sdn.sitecore.net/Articles/API/Creating%20a%20Composite%20Custom%20Field.aspx
Since I do need the labels (which need to be translated) and the name value list field doesn't allow duplicate keys we changed our approach.
this was going to be used to input multiple phone numbers, e-mail addresses etc.
In stead we opted to go with separate templates that would be inserted as child items.

Sitecore - What are the pitfalls of storing content in the renderings field

I'd like to know if anyone has had experience of using rendering parameter fields in Sitecore to store content. If so, what drawbacks are there?
In some respects, this seems like an attractive idea as you can add a sublayout to a page numerous times without needing to create child items and setting each sublayout's datasource to one of these child items.... however putting content into renderings fields has a few disadvantages:
This solution is not localizable since the renderings field is shared, so no good for multi-language sites.
To edit the content (if using the content editor) you need to switch to the presentation tab, click details, select the sublayout then edit the rendering parameters which is all a bit cumbersome.
Are there any more serious consequences of adopting this approach?
There is no way to apply workflow to the fields.
There is no way to enable the fields for the page editor.
You can accomplish this just as easily by using the Page Editor and setting a Datasource Template and Datasource Location on your sublayout.
I'll reiterate something you already pointed out -- it's a shared field, so the content can't be localized.
There's no way to reuse the content stored in parameter fields.
Even if you DID do it, its hard to get the data from the parameters because they are XML-based (hint: add an Image to rendering parameters and look at what value you get back)
Overall, you are breaking the separation of content and presentation that the layout field is intended to provide. Please don't do this, one day a developer following in your footsteps will come across it and then spend all day on http://nooooooooooooooo.com/.

Keping history in Winforms C++

I have an application made in winform using C++ (developed in VS 2010). The GUIs have certain text fields, radio button, check boxes etc. To operate the software one has to fill in these fields/buttons/boxes etc.
There are roughly such 50 different GUIs, having roughly 20 fields in each one.
I want that after the application is closed, and restarted, most recent parameters in this fields automatically fill in, so the user do not need to re-enter all those values again.
What is the easiest and simplest way to achieve this?
This is best solved using MVC pattern where the Model contains the data that was filled. The view contains the way it will be presented(such as in Winforms) And lastly the controller which besides doing business logic will need to do some work (for saving the state).
I prefer using serialization for this. You can serialize the model fields and read them back(fields that are necessary only).
If you don't like serialization you can try writing to INI files that will be easy to modify.
Thirdly you can use a database mdf file to store the state.
But to do all this well you will need to modify the App to use MVC architecture.
You can use the Windows Registry with
WindowsFormName (subkey)
---------> ControlName (subkey)
-----------------> ControlValue (subkey)
When the Form is Closing you save the values for each control in the Registry
When the Form is Loading you read the values
If you are satisfied with a quick and dirty solution you can try this:
Implement a save mechanism:
Iterate to all the form controls (recursively if there are panels or
other containers)
If the control is edit (or other type that holds
data) save the control text together with his name
Store the name,
value pairs (INI file for example)
Implement a load mechanism. This assumes that there are no dependencies between values (If there are automated computed fields do not save them)
Load the values from the storage (if you choose files the file name can be the form name)
iterate to all the form controls and if you find its name in loaded data set the value
Once implemented this approach can be used for all the forms and it will cope with adding/removing controls. However if there are business rules maybe is better to use a MVC approach and serialize the model.

Saving user's data for my application

I was wondering what would be the correct method for saving all user data for an application I am working on. The application is in QT. The user inputs a lot of data into the application and the data will be different for every user. I want the ability for the user to save all the current data to a file that can be user by the loaded by the application again once the user wants to use it again or use it on another computer running the application.
What would be the correct and best way to do this? Do I need to use xml format? And then use the xmlreader for QT? Or do I just need to create my own file format and just use the stream to just read everything in. The data in the file will need to be labeled, because it will need to put the data in certain spots on the gui. And the user has the option to dynamically create boxes and tabs that hold certain information.
If you need any more information, please let me know.
A short example:
I am not only reading gui locations.
But the contents of those. For
instance. The user is able to create
tabs that contain edit text boxes. And
those tabs are associated with items
that are in a list. When the user
clicks on an item in the list the user
will be presented with a whole set of
new tabs. And each tab has some
editing forms. The file will need to
contain what is in the list, what tabs
the user has created under each item
in that list and the contents of each
tab associated with the tab of each
item in the list.
In essense, yes you'll be creating your own file format, but the actual content can just be XML in whatever scheme you need. Then you can use Qt's built-in XML processing capabilities to pull the heavy lifting of parsing the text (I personally prefer the DOM model, so I use QDomDocument as my base point), and you'll just need to worry about parsing things to and from the individual nodes.
The Qt framework has some great XML samples if I remember correctly that helped me get off the ground almost immediately. Hope they help!
Another great solution is to use internal database implementation (QSQL on top of sqlite). Compared to the xml solution, it might be more versatile (update when needed, can use external keys). Qt has some rgeat examples about using it aas well.
In terms of dependencies, XML solution will require you to use xml and xmlpatterns (if you want to validate stuff), whereas sqlite solution will require QSQL + sqlite plugin. I think that sqlite guarantees atomicity of writing , thus preventing corruption of data (think : the user is killing the app while it's saving).

Dynamically Update a Form in Django AFTER Initial Creation/Display

Is there away to dynamically modify and validate a Django form AFTER it's been created and displayed.(I have found a few snippets that show dynamic form creation, but these require that the dynamic fields are known/defined prior to creating the form.) My requirement is different.
Use Case:
I have a form where I want to display and validate additional input fields based on the selection from a dropdown on the initial form. Based on the selection additional fields are 1) added and 2)must then be validated with appropriate error handling.
(In case you are wondering the data elements to be added are a set of name/value pairs stored in csv format in the model, but when displayed they are shown as separate input fields - the input data will be converted to a csv string prior to saving).
I got this partially working using ajax to dynamically add the additional fields to a template, but have not found a way to validate these new fields. I'm not sure if this is a workable approach. I could probably do this in the browser using javascript, but would prefer a Django/server side solution.
OK - So none responded to my question so far. However I did a bit more googling and found an excellent article that describe the solution I was looking for. Major Kudo's to the author of this blog.
Create a Django Dynamic Form with JQuery - Dynamic Field Addition and Removal