Custom Content Module SF 4.1 SP2+ / SF 4.2

Posted by Community Admin on 04-Aug-2018 00:29

Custom Content Module SF 4.1 SP2+ / SF 4.2

All Replies

Posted by Community Admin on 11-Aug-2011 00:00

Hello-

I have a custom module that is a copy of the Products Module that was customized to extend the standard content base module.  It has some additional fields all that work as expected.  The built in content fields (Title, Content, URL, etc...) do not save when the item is published or saved as a draft.  The code for this module worked perfectly in SF 4.1 SP1 and 4.1 but something has changed and it no longer works the same.

I've looked at the blog post with the Sample Locations module and have even used it as a template and ran into the same issues.

Any help or guidance on how to proceed would be appreciated.

Thanks,

-Thomas

Posted by Community Admin on 11-Aug-2011 00:00

Hi Thomas,

Please check whether you have created your custom fields for the ProductItem. You can use System.ComponentModel.TypeDescriptor.GetProperties( object);
If the properties are not created you should add them

App.WorkWith().DynamicData().Type(typeof(ProductItem)).Field().TryCreateNew("mycustomfield", null).SaveChanges();



Greetings,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 11-Aug-2011 00:00

Ivan-

Yes they are there.  My custom fields save and load perfectly.  The only fields that do not load are the ones provided as part of the base content object.

Thanks,

-Thomas

Posted by Community Admin on 16-Aug-2011 00:00

Hello Thomas,

Excuse us for the belated response.

Could you send us your project and database (or give us a link to download from if those are more than the allowed attachment size)? This will allow us to diagnose the issue much more quickly.

Regards,
Radoslav Atanasov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 26-Aug-2011 00:00

I'm having the same issue even with a vanilla install of the products module. The title and the description are not saving although all the other items are (e.g. color, price, quanity). I tried the products module directly because I was having a similar issue with a custom module. Any information on how to avoid this?

Posted by Community Admin on 29-Aug-2011 00:00

Hi Kmac and Thomas,
Can you check your ProducstDefintions.cs file for the definition of the title and content  field controls.

The most current definition should be like the quoted bellow (notice the usage of "Title.PersistedValue" for DataFieldName). The PersistedValue property is used only when binding Lstring fields(multilingual text fields), this property is used because one can optionally write a Resource expression that is later evaluated as real text from a resource package. So the PersistedValue is the original expression (or plain text), and Value(the default property) - keeps the evaluated expression or plain text. Bottom line is that we now bind all multilingual fields to PersistedValue in Edit mode and if your module is using old code that doesn't saving of this fields would not work.

var titleField = new TextFieldDefinitionElement(mainSection.Fields)
           
                ID = "titleFieldControl",
                DataFieldName = (displayMode == FieldDisplayMode.Write) ? "Title.PersistedValue" : "Title",
                DisplayMode = displayMode,
                Title = "lTitle",
                CssClass = "sfTitleField",
                ResourceClassId = typeof(ProductsResources).Name,
                WrapperTag = HtmlTextWriterTag.Li,
            ;

also for the Content field (notice the usage of Content.PersistedValue:


            var contentField = new HtmlFieldElement(mainSection.Fields)
           
                ID = "contentFieldControl",
                DataFieldName = (displayMode == FieldDisplayMode.Write) ? "Content.PersistedValue" : "Content",
                DisplayMode = displayMode,
                CssClass = "sfFormSeparator sfContentField",
                ResourceClassId = typeof(ProductsResources).Name,
                WrapperTag = HtmlTextWriterTag.Li,
                EditorContentFilters = Telerik.Web.UI.EditorFilters.DefaultFilters,
                EditorStripFormattingOptions = (Telerik.Web.UI.EditorStripFormattingOptions?)(Telerik.Web.UI.EditorStripFormattingOptions.MSWord | Telerik.Web.UI.EditorStripFormattingOptions.Css | Telerik.Web.UI.EditorStripFormattingOptions.Font | Telerik.Web.UI.EditorStripFormattingOptions.Span | Telerik.Web.UI.EditorStripFormattingOptions.ConvertWordLists)
            ;
            mainSection.Fields.Add(contentField);

Same goes for the UrlName field it should use:

DataFieldName = (displayMode == FieldDisplayMode.Write) ? "UrlName.PersistedValue" : "UrlName", 



Regards,
Nikolay Datchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Posted by Community Admin on 29-Aug-2011 00:00

That worked like a charm, Nikolay. Thank you. I just used the productmodule visual studio template that comes with the SDK to get started so I think you might need to update that code in there.

Thanks again

This thread is closed