Extend Generic Module with custom fields

Posted by Community Admin on 03-Aug-2018 17:21

Extend Generic Module with custom fields

All Replies

Posted by Community Admin on 01-Mar-2011 00:00

Hi,

Is there a documentation on how to extend the generic module with custom fields?

I've read somewhere you could do that, but couldn't see the documentation anywhere...

Thanks

Posted by Community Admin on 01-Mar-2011 00:00

Hello Larry,

Yes, you can do that. Please take a look at Adding custom fields to content items section in the User Guide.
 If you need any further information, please do not hesitate to contact me.


All the best,
Boyan Barnev
the Telerik team

Posted by Community Admin on 11-Jan-2012 00:00

Is it possible to add custom fields to Classifications too?  I'm not seeing "Custom Fields for <content type>" link in that section.

Posted by Community Admin on 12-Jan-2012 00:00

Hello Seattle Web Group,

Classifications are not content-based modules, but rather a mechanism to classify your content, and as such they do not have custom fields (a classification itself represents a dynamic field for  the content item it's assigned to). Can you please share with us what's the desired functionality, I believe we might be able to come up with an advice/workaround?

Greetings,
Boyan Barnev
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 12-Jan-2012 00:00

Hi Boyan,

In addition to the description we've got some additional content that will be displayed in multiple locations that's associated with each category.  Rather than having this information loosely shared through content blocks it would be ideal if the information could be entered as part of the data for the categories themselves.  If there isn't an API that allows us to add custom fields to a classification then the solution will probably end up being creating a custom module that will emulate the classification functionality.

Posted by Community Admin on 17-Jan-2012 00:00

Hi,

Theoretically, you can convert almost any type to DynamicType and then add custom fields to it, so it might be possible for Taxon(the base class from which or classifications derive) as well. For example:

var metaManager = Telerik.Sitefinity.Data.Metadata.MetadataManager.GetManager();
metaManager.CreateMetaType(typeof(Taxon));
metaManager.SaveChanges();
 
App.WorkWith().DynamicData().Type(typeof(Taxon)).Field().TryCreateNew("Test", typeof(String)).SaveChanges(true);
Please execute this code only once, and do not forget to back up your database beforehand. I've tested it on my local project and was able to programatically store and later retrieve data from the field, and the category was still usable in Sitefinity, however we have not tested this functionality thoroughly so I'd advice you to be cautious.
You can operate with your new field using our extension methods GetValue() and SetValue() like this:
var manager = TaxonomyManager.GetManager();
            var myCat = manager.GetTaxa<HierarchicalTaxon>().Where(t => t.Name == "cat1").SingleOrDefault();
            var testValue = "Some value 1111";
            myCat.SetValue("Test", testValue);
            myCat.GetValue<String>("Test");

Please do not hesitate to let me know if y9ou need any additional information or any further assistance. It was a pleasure for me to help you on this issue.

Greetings,
Boyan Barnev
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 17-Jan-2012 00:00

Thank You Boyan,

That's very helpful.  It's going to be interesting putting the forms together for this since everything is going to need to be an LString to allow for foreign language content.

Posted by Community Admin on 18-Jan-2012 00:00

Hello,

That's a tough one, unfortunately LString is not a supported type for dynamic fields in Sitefinity, yet. We're working on implementing this functionality for some upcoming release, in the meantime you can just make a separate field for each language as a workaround.

Greetings,
Boyan Barnev
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

This thread is closed