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

Forums / Developing with Sitefinity / Can't add Custom Meta Fields?

Can't add Custom Meta Fields?

12 posts, 0 answered
  1. Doug
    Doug avatar
    34 posts
    Registered:
    20 Apr 2010
    07 Jun 2010
    Link to this post
    Hello,
       I am referencing this document and it is instructing me to modify /Sitefinity/Admin/ControlTemplates/News/ControlPanelInsert/Edit.ascx  but the problem is that the only files I found that had this name where in the Testimonials directory and they didn't seem to be the ones that control the News section.   Should I be looking ina nother section or?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    07 Jun 2010
    Link to this post
    Hi Doug,

    You have to map the external templates - How to map a template for the desired view.

    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.
  3. Doug
    Doug avatar
    34 posts
    Registered:
    20 Apr 2010
    07 Jun 2010
    Link to this post
    Hi Ivan,
       Thanks for the link but the instructions there do not appear to work?  I have created the XML file underneath App_Data in a folder named configuration and have added this bit of code to it:
    <controlsConfig>
      <viewMap>
        <!--Provides user interface for editing a news item in the News module.-->
        <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemEdit" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsItemEdit.ascx" />
        <!--Provides user interface for adding new news items in the News module.-->
        <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemNew" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsItemNew.ascx" />
      </viewMap>
    </controlsConfig>

    I then copied the templates specified above from the Extneral Templates zip file into the stated location. I then copied the necessary resx files to the App_LocalResources folder within the NewsFolder.  I then added a bit of test text to the control NewsItemEdit to make sure everything was working.  I logged into SiteFinity, went to the News Module, and created a new news item and my test text was not there.  Further I searched through the source of the page to see if maybe it was hidden for some reason and it was not there either. 
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    07 Jun 2010
    Link to this post
    Hi Doug,

    Have you restarted the application as suggested in the KB?

    Sincerely yours,
    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. Doug
    Doug avatar
    34 posts
    Registered:
    20 Apr 2010
    08 Jun 2010
    Link to this post

    I apparently read over that.  In any event, stoping and starting cassini did the trick.

    Now I have a requirement to modify the look and feel of the forward facing template (/sitefinity/controltemplates/News/) which wasn't a problem, I jumped in and changed the styles and all was good. However I have a requirement to limit the number of characters that are displayed from the summary and replace anything beyond this number with '...'. 

    Now I tried hooking the ItemDataBound event of the repeater that sets inside ListPageManager.ascx but the literal always has a Text length of 0.  Below is my snippet of code that I added to the ascx file

    <script language="C#" runat="server">
      
        public string CharacterLimit(string Value)
        {
            if (Value.Length <= 170) return Value;
            return (String.Format("{0}...", Value.Substring(0, 169))); 
        }
      
        protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Literal content = (Literal)e.Item.FindControl("Summary");
                content.Text = CharacterLimit(content.Text);
            }
        }
    </script>

    Am I able to hook this in someway or am I stuck? Thanks.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    08 Jun 2010
    Link to this post
    Hi Doug,

    You could try using the workaround provided here.

    Best wishes,
    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.
  7. Doug
    Doug avatar
    34 posts
    Registered:
    20 Apr 2010
    08 Jun 2010
    Link to this post
    Thanks Ivan. Per this comment: "Here we have TargetID="Summary" which means that our settings will apply to the summary metafield of news items. If you change the ID to "content" your settings will apply to the News content." I indeed tried to do this but I am not getting a prompt to limit the content field, only the summary field (screen shot attached). 

    This is the code I added to the <MasterSettings> element:
    <sfDesignSettings:ContentSetting id="ContentSetting1" TargetID="content">   
                        </sfDesignSettings:ContentSetting>

    Thanks.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    09 Jun 2010
    Link to this post
    Hi Doug,

    You can control the settings only for the summary. The control works in the same way for Events. Anyway you could override the EventsView control and its SetItemMetadata method from where you could access the content item and all controls inside the repeater of the template.  You could use SummarySettings class to filter the item content.

    SummarySettings settings = new SummarySettings(SummarySettings.SummaryMode.Words, 30, true, new string[] { });
       
    string cntText = (string)cntItem.Content;
    string newText = SummaryParser.GetSummary(cntText, settings);



    The SummarySettings  works with words but you could get the whole content and then get index of n chars. The third parameter that I pass to SummarySettings is of boolean type and it indicates whether all not alpha numeric chars will be removed. Then SummaryParser returns the "filtered" text as a string.


    SummaryMode is enum

    • None -Indicates that the whole text should be displayed.
    • Words - Indicates that the summary should be created by cropping the specified number of words.
    • Sentences -   Indicates that the summary should be created by cropping the specified number of sentences.
    • Paragraphs   - Indicates that the summary should be created by cropping the specified number of paragraphs
    • MetaField - Indicates that the content of a specified meta field will be used for summery.


    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.
  9. Doug
    Doug avatar
    34 posts
    Registered:
    20 Apr 2010
    09 Jun 2010
    Link to this post
    Hi Ivan,
       Thanks for that.  I suppose I should follow the instructions given here for creating a new control that will override the method: http://www.sitefinity.com/devnet/forums/sitefinity-3-x/bugs-issues/events-view-displays-publication-date-not-event-start-date-ignores-description.aspx

    Thanks.
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    09 Jun 2010
    Link to this post
    Hello Doug,

    Yes the instructions are correct. You also have to override the template properties

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Events.WebControls;
    using Telerik.Cms.Engine.ContentViewFiltering;
    using Telerik.Cms.Engine;
    using System.Web.UI;
    using System.Web.UI.WebControls;
     
    /// <summary>
    /// Summary description for EventsViewCustomControl
    /// </summary>
    public class EventsViewCustomControl : EventsView
    {
        public EventsViewCustomControl()
        {
            //
            // TODO: Add constructor logic here
            //
        }
     
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/Admin/ControlTemplates/Events/Modes/ListPageMaster.ascx";
            }
     
        }
     
        public override string SingleItemTemplatePath
        {
            get
            {
                return "~/Sitefinity/Admin/ControlTemplates/Events/Modes/ListPageDetail.ascx";
            }
     
        }
        protected override void SetItemMetadata(Control itemContainer, IContent contentItem)
        {
            base.SetItemMetadata(itemContainer, contentItem);
          
     
     
        }
     
     
     
         
     
    }


    Sincerely yours,
    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.
  11. Doug
    Doug avatar
    34 posts
    Registered:
    20 Apr 2010
    09 Jun 2010
    Link to this post
    Hi Ivan,
        Thank you that and forgive my ignorance on this but this control seems to be focused on the Events module as opposed to the News module.  By creating this custom control as outlined above this will override the display of news items correct?
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    09 Jun 2010
    Link to this post
    Hello Doug,

    The methods and properties in NewsView are the same. Both the controls inherits from ContentView class, so there is no difference event if you use BlogPosts, ImageGallery, DownloadList controls.

    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.
Register for webinar
12 posts, 0 answered