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

Forums / Developing with Sitefinity / how to add meta field in create page ?

how to add meta field in create page ?

6 posts, 0 answered
  1. Björn
    Björn avatar
    11 posts
    Registered:
    29 Nov 2007
    28 Dec 2010
    Link to this post
    hi,

    how to add meta field in the properties of create page  in sitefinity 3.7? i want to add some custom field in the properties of create page.please see the attachment. please provide some example and guide about it.

    thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Dec 2010
    Link to this post
    Hi Björn,

    Please take a look at



    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Björn
    Björn avatar
    11 posts
    Registered:
    29 Nov 2007
    30 Dec 2010
    Link to this post
    Hi,

    i follow the reference given by you. i made one my custom table. i am able to insert and delete the custom metal field for pages. the problem only arrive in page edit mode.  the problem is

    1.in page edit mode the IsPostBack is always true( in page properties);

    2. if i remove !IsPostBack check. then correct meta field value is not showing correctly in meta field. when i clicked twice on the page(in edit mode then it will show correct one).

    here is the code befinind of my PagePropertiesEdit.ascx page. please see the attachment also for better understanding.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Cms.Data;
    using Telerik.Cms;
    using System.Data.Common;
    using System.Data;
     
    public partial class Sitefinity_Admin_ControlTemplates_Pages_PagePropertiesEdit : System.Web.UI.UserControl
    {
     
        private CmsPage UpdatePage { get; set; }
        Guid mypageID = Guid.Empty;
        public string rl = string.Empty;
        protected override void OnInit(EventArgs e)
        {
            CmsManager.Executed += new EventHandler<Telerik.ExecutedEventArgs>(CmsManager_Executed);
            base.OnInit(e);
        }
     
        void CmsManager_Executed(object sender, Telerik.ExecutedEventArgs e)
        {
            if (e.CommandName.Equals("UpdatePage"))
                UpdatePage = e.Data as CmsPage;
        }
     
        protected override void OnUnload(EventArgs e)
        {
            if (UpdatePage != null)
            {
                DbCommand comm = GenericDataAccess.CreateCommand();
                comm.CommandText = "hg_PageMetaFields_upd";
                DbParameter param = comm.CreateParameter();
                param.ParameterName = "@SubmenuPosition";
                param.Value = Convert.ToInt32(RightLeft.SelectedValue);
                param.DbType = DbType.Int32;
                comm.Parameters.Add(param);
     
                //second Paramaters
                param = comm.CreateParameter();
                param.ParameterName = "@isSpace";
                param.Value = Convert.ToInt32(spacerequire.SelectedValue.ToString());
                param.DbType = DbType.Int32;
                comm.Parameters.Add(param);
     
                //Third Paramaters
                param = comm.CreateParameter();
                param.ParameterName = "@PageID";
                param.Value = new Guid(UpdatePage.ID.ToString());
                param.DbType = DbType.Guid;
                comm.Parameters.Add(param);
     
                GenericDataAccess.ExecuteNonQuery(comm);
     
     
            }
        }
     
        protected void Page_Load(object sender, EventArgs e)
        {
     
            mypageID = ((Telerik.Cms.Web.UI.PageEditor)(this.Parent.Parent.Parent.Parent.Parent.Parent)).SelectedPageId;
     
            if (!IsPostBack)
           {
                if (mypageID != null)
                {
     
                    DbCommand comm = GenericDataAccess.CreateCommand();
                    comm.CommandText = "hg_PageMetaFields_pkq";
                    DbParameter param = comm.CreateParameter();
                    param.ParameterName = "@PageID";
                    param.Value = mypageID;
                    param.DbType = DbType.Guid;
                    comm.Parameters.Add(param);
                    DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);
                    foreach (DataRow row in table.Rows)
                    {
                        RightLeft.Text = row["SubmenuPosition"].ToString();
                        spacerequire.Text = row["isSpace"].ToString();
                    }
     
                }
            }
     
            
     
        }
     
       
     
     
    }

    please  guide and provide step by step procedure to solve this problem.

    thanks
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Jan 2011
    Link to this post
    Hi Björn,

    The CmsManager_Executed is not called when you update the page properties, so you cannot rely on its events when you make modifications to the page properties. Actually this implantation is based on whether you click edit /save buttons. You can use AutoPostBack property of RadioButton and RadioButtonList controls which should solve the issue with the selection.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Björn
    Björn avatar
    11 posts
    Registered:
    29 Nov 2007
    13 Jan 2011
    Link to this post
    Hi,
     
    this is the continuous of previous(above) post. so please answer by understanding the flow( from previous).

    1.can you give some example  how to do it ?

    2.suppose there is page which name is A. and page A has four sub pages b,c,d and e. i have using following code to select the selected page .

    mypageID = ((Telerik.Cms.Web.UI.PageEditor)(this.Parent.Parent.Parent.Parent.Parent.Parent)).SelectedPageId;

    when i click  b page , it show the page id of b . after that when i click c or d or e page , it always give the page id of b. means the always show the first select page .

    please provide some example and guide how to solve this.

    thanks
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 Jan 2011
    Link to this post
    Hi Björn,

    Edit /Save buttons can be accessed from the templates described in the forum posts I gave you.

    You need to add

     mypageID = ((Telerik.Cms.Web.UI.PageEditor)(this.Parent.Parent.Parent.Parent.Parent.Parent)).SelectedPageId;

    inside PreRender.

    Greetings,
    Ivan Dimitrov
    the Telerik Dev team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
6 posts, 0 answered