1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Extend Generic Module with custom fields

Extend Generic Module with custom fields

8 posts, 0 answered
  1. Larry
    Larry avatar
    39 posts
    Registered:
    30 Dec 2010
    01 Mar 2011
    Link to this post
    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
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    01 Mar 2011
    Link to this post
    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
  3. Seattle Web Group
    Seattle Web Group avatar
    29 posts
    Registered:
    03 May 2011
    11 Jan 2012
    Link to this post
    Is it possible to add custom fields to Classifications too?  I'm not seeing "Custom Fields for <content type>" link in that section.
  4. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    12 Jan 2012
    Link to this post
    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
  5. Seattle Web Group
    Seattle Web Group avatar
    29 posts
    Registered:
    03 May 2011
    12 Jan 2012
    Link to this post
    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.
  6. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    17 Jan 2012
    Link to this post
    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
  7. Seattle Web Group
    Seattle Web Group avatar
    29 posts
    Registered:
    03 May 2011
    17 Jan 2012
    Link to this post
    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.
  8. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    18 Jan 2012
    Link to this post
    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
8 posts, 0 answered