More in this section
Forums / Bugs & Issues / Custom Fields for Pages

Custom Fields for Pages

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
4 posts, 0 answered
  1. Antoine
    Antoine avatar
    45 posts
    Registered:
    13 Jul 2012
    11 May 2011
    Link to this post
    I'm trying to add custom fields to our pages by running the code supplied here:

    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/can-tags-and-categories-be-applied-to-a-page.aspx#1580529

    I'm getting the following error when running the code provided in the above example:

    Specified type 'Telerik.Sitefinity.Pages.Model.PageData' is not a dynamic type.

    [InvalidOperationException: Specified type 'Telerik.Sitefinity.Pages.Model.PageData' is not a dynamic type.]
       Telerik.Sitefinity.Fluent.DynamicData.DynamicTypeFacade.LoadDynamicType(Type existingType) +734
       Telerik.Sitefinity.Fluent.DynamicData.DynamicTypeFacade..ctor(AppSettings appSettings, Type existingType) +40
       Telerik.Sitefinity.Fluent.FluentDynamicData.Type(Type existingType) +30
       SitefinityWebApp.Widgets.PageList.PageList.Page_Load(Object sender, EventArgs e) in C:\Projects\CMS_Playground\Sitefinity_Sandbox\Sandbox.FloridaJobs\Widgets\PageList\PageList.ascx.cs:28
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnLoad(EventArgs e) +91

    Any ideas?

    Thanks!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    13 May 2011
    Link to this post
    Hello Antoine,

    It looks like the PageData is not created as a dynamic meta type

    var metaManager = Telerik.Sitefinity.Data.Metadata.MetadataManager.GetManager();
     
    var type = metaManager.CreateMetaType(typeof(Telerik.Sitefinity.Pages.Model.PageData));
     
    metaManager.SaveChanges();


    Regards,
    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
  3. Clay
    Clay avatar
    1 posts
    Registered:
    06 May 2011
    13 May 2011
    Link to this post
    Thanks Ivan! I'm taking over this issue for Antoine. I was able to successfully add the field after running the code above. Now, I'm trying to set the value using the code provided here:

    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/sdk/custom-page-attributes.aspx#1479797

    App.WorkWith().DynamicData().Type(typeof(PageData)).Field().TryCreateNew("MyPageDataField", typeof(string)).SaveChanges(true);
    var dynamicContent = App.WorkWith().DynamicData().Fields().Where(dc => dc.FieldName == "MyPageDataField").Get();
    var pg = App.WorkWith().Pages().Where(pk => pk.Name == "somename").Get().SingleOrDefault() as PageNode;
    pg.Page.SetValue("MyPageDataField", "somevalue");

    However, there's no SetValue() method on the PageData class. Has this changed in a recent release?

    Thanks much!
    Clay
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    16 May 2011
    Link to this post
    Hello Antoine,

    Do you have a reference to  Telerik.Sitefinity.Model; (using Telerik.Sitefinity.Model;)

    Best wishes,
    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
4 posts, 0 answered