Custom Fields for Pages

Posted by Community Admin on 04-Aug-2018 21:30

Custom Fields for Pages

All Replies

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

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!

Posted by Community Admin on 13-May-2011 00:00

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

Posted by Community Admin on 13-May-2011 00:00

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

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

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

This thread is closed