MetaDetail Add for the newly created Blog Posts & News - General Discussions - General Discussions - Progress Community
 General Discussions

MetaDetail Add for the newly created Blog Posts & News

  • MetaDetail Add for the newly created Blog Posts & News
  • As per the requirement, Need to create Meta Title, Meta Description & Meta Keywords for all of the pages which will be available after creating of an every individual blog posts & news.

    One of the solution which I have tried was as mentioned (This was taken from here ):

    Step 1 : Create custom fields inside the blog post

    Step 2 : Use of an ActionFilter

    namespace SitefinityWebApp
        /// <summary>
        /// Blog Attribute
        /// </summary>
        public class BlogMetaAttribute : ActionFilterAttribute
            /// <summary>
            /// MetaTitle variable
            /// </summary>
            public string MetaTitle get; set;
            /// <summary>
            /// Override the on Action Executing
            /// </summary>
            /// <param name="filterContext"></param>
            public override void OnActionExecuting(ActionExecutingContext filterContext)
                if (filterContext.Controller.GetType() == typeof(NewsController) && filterContext.ActionDescriptor.ActionName == "Details")
                    var actionParameters = filterContext.ActionParameters as IDictionary<string, object>;
                    var newsItem = actionParameters["newsItem"] as NewsItem;
                    if (newsItem != null)
                        this.MetaTitle = newsItem.Title;
            /// <summary>
            /// Register Events
            /// </summary>
            private void Register()
            /// <summary>
            /// </summary>
            /// <param name="event"></param>
            private void OnPagePreRenderCompleteEventHandler(IPagePreRenderCompleteEvent @event)
                if (!string.IsNullOrEmpty(this.MetaTitle))
                    HtmlMeta tag = new HtmlMeta();
                    tag.Attributes.Add("property", "title");
                    tag.Content = this.MetaTitle;

    Step 3  : Filter simply register in the Global.asax

    protected void Application_Start(object sender, EventArgs e)
        Bootstrapper.Initialized += this.Bootstrapper_Initialized;
    private void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
        if (e.CommandName == "Bootstrapped")
            GlobalFilters.Filters.Add(new FacebookMetaAttribute());

    Still unable to load meta detail inside the page
  • I met the same situation with meta title and meta description. 

    I just copied source code of existing News widget. Renamed it to Custom News widget. Added new fields (title, description and keywords) to model.

    And in controller Details action added

    ViewBag.Title = "something here";

    ViewBag.Title automatically overrides old titile

    You can find source code of News widget here: