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

Forums / Developing with Sitefinity / News Code problems

News Code problems

5 posts, 0 answered
  1. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    02 Sep 2010
    Link to this post
    Can someone look at this and tell me where my issues are?

    #region[Post]
    private void GetPostByID()
    {
        Telerik.News.NewsManager manager = new Telerik.News.NewsManager("News");
        IList listOfAllNews = manager.GetNews();
        Guid selectedPostGuid = new Guid();
        DropDownList Reporter = FindControlRecursive(MetaFields, "Reporter") as DropDownList;
        foreach (INews NewsItem in listOfAllNews)
        {
            Guid parentId = NewsItem.ID;
            IList allposts = manager.GetPosts(string.Empty, NewsItem.ID, NewsItem.ID);
            selectedPostGuid = new Guid(Common.QueryString("Param"));
            foreach (IContent post in allposts)
            {
                if (post.ID == selectedPostGuid)
                {
                    Reporter.SelectedValue = (string)post.GetMetaData("Reporter");
                    break;
                }
            }
        }
    }
    #endregion
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Sep 2010
    Link to this post
    Hello Steven Lancaster,

    Could you explain what the problem is and what you want to do?

    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
  3. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    02 Sep 2010
    Link to this post
    I am sorry. I have a metafield named reporters I am trying to associate a News story with a certain reporter that is done from a drop down list.


    Ok let me say this and maybe you have a better answer for me. I need to set up reporters in my site and have them associated with news stories and then if you go to the reporters BIO for lack of a better term it will display all stories done by that reporter. Also I may have 2 reporters that have collaberated on 1 story so I need to associate both of them to the same story. I want this done so that the user does not have to type it in. So they can put in a news story select associated reporters and I can call those stories by reporter or Vice versa.
  4. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    02 Sep 2010
    Link to this post
    Let me show you both my pages.

    NewsItemNew.ascx














    <%@ Control Language="C#" CodeFile="NewsItemNew.ascx.cs" Inherits="Sitefinity_Admin_ControlTemplates_News_NewsItemNew"  %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Engine.WebControls" Assembly="Telerik.Cms.Engine" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Web.UI" Assembly="Telerik.Cms.Web.UI" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Engine.WebControls.Admin" Assembly="Telerik.Cms.Engine" %>
    <%@ Register TagPrefix="sfLib" Namespace="Telerik.Libraries.WebControls" Assembly="Telerik.Libraries" %>
      
    <div class="ToolsAll">
        <div class="backWrapp">
            <asp:HyperLink ID="BackButton1" runat="server" CssClass="actions back" causesvalidation="false"><asp:Literal ID="Literal1" runat="server" Text="<%$Resources:BackToAllNewsItems %>"></asp:Literal></asp:HyperLink>
        </div>
    </div>
    <div id="divWorkArea" runat="server" class="workArea insert">
        <sf:MessageControl runat="server" ID="message1">
            <ItemTemplate>
                <asp:Label runat="server" ID="messageText"></asp:Label>
            </ItemTemplate>
        </sf:MessageControl>
        <div class="mainForm">
        <p class="mand">* <asp:Literal ID="Literal4" runat="server" Text="<%$Resources:MandatoryFields %>"></asp:Literal></p
        <h3><asp:Label ID="Label1" AssociatedControlID="Title" runat="server"><asp:Literal ID="Literal2" runat="server" Text="<%$Resources:Title %>"></asp:Literal> * <em id="TitleLabel" runat="server"></em></asp:Label></h3>
        <fieldset class="set">
            <div class="setIn title">
                <asp:TextBox ID="Title" Text="<%$Resources:TitleInput %>" runat="server" MaxLength="250" ValidationGroup="InsertNews"></asp:TextBox>    
                <asp:RequiredFieldValidator ID="validator1" runat="server" ControlToValidate="Title" Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True" ValidationGroup="InsertNews"><strong><asp:Literal ID="Literal5" runat="server" Text="<%$Resources:TitleEmpty %>"></asp:Literal></strong></asp:RequiredFieldValidator>
            </div>
        </fieldset>
        <div class="bottom"><div><!-- --></div></div>                  
        <h3><asp:Literal ID="Literal3" runat="server" Text="<%$Resources:Content %>"></asp:Literal> * <em id="contentEditorLabel" runat="server"></em></h3>                
        <fieldset class="set">                    
                <div class="setIn">
                    <telerik:RadEditor 
                        runat="server" 
                        ID="Editor"
                        ContentAreaCssFile="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorContentArea.css"
                        ToolsFile="~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml"                   
                        Skin="WebBlue"                     
                        NewLineBr="False"
                        Width="95%"
                        ContentFilters="EncodeScripts,FixUlBoldItalic,FixEnclosingP,IECleanAnchors,MozEmStrong,ConvertFontToSpan,ConvertToXhtml,IndentHTMLContent"
                        <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" DeletePaths="~/Images" />
                        <MediaManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
                        <FlashManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
                        <DocumentManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
                        <CssFiles>
                            <telerik:EditorCssFile Value="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorCssFile.css" />
                        </CssFiles>
                    </telerik:RadEditor>
                    <script type="text/javascript">
      
                    Telerik.Web.UI.Editor.CommandList["LibraryImageManager"] = function(commandName, editor, args)
                    {
                       var editorArgs = editor.getSelectedElement();
                       if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                            editorArgs = editor.getSelection();
                         
                       var myCallbackFunction = function(sender, args)
                       {
                            if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "IMG")
                                args.parentNode.replaceChild(editorArgs, args);
                            else
                            {
                                var cloned = args.cloneNode(true);
                                var div = args.ownerDocument.createElement("DIV");
                                div.appendChild(cloned);
                                editorArgs.pasteHtml(div.innerHTML);
                            }
                       }
                       editor.showExternalDialog(
                       '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx") %>',
                       editorArgs, 
                       750, 
                       600, 
                       myCallbackFunction, 
                       null, 
                       'ImageLibraryDialog', 
                       true, 
                       Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
                       false, 
                       true)
                    };
      
                    Telerik.Web.UI.Editor.CommandList["LibraryDocumentManager"] = function(commandName, editor, args)
                    {
                       var editorArgs = editor.getSelectedElement();
                       if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                            editorArgs = editor.getSelection();
                         
                       var myCallbackFunction = function(sender, args)
                       {
                            if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                                args.parentNode.replaceChild(editorArgs, args);
                            else
                            {
                                var cloned = args.cloneNode(true);
                                var div = args.ownerDocument.createElement("DIV");
                                div.appendChild(cloned);
                                editorArgs.pasteHtml(div.innerHTML);
                            }
                       }
                       editor.showExternalDialog(
                       '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/DocumentEditorDialog.aspx") %>',
                       editorArgs, 
                       750, 
                       600, 
                       myCallbackFunction, 
                       null, 
                       'ImageLibraryDialog', 
                       false, 
                       Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
                       false, 
                       true)
                    };
      
                    Telerik.Web.UI.Editor.CommandList["LinkManager"] = function(commandName, editor, args)
                    {
                       var editorArgs = editor.getSelectedElement();
                       if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                       {                                                                   
                            var sel = editor.getSelection();  
                            editorArgs = sel;
                            editorArgs.Html = sel.getHtml();
                            editorArgs.Text = sel.getText();                                    
                       }
                         
                       var myCallbackFunction = function(sender, args)
                       {
                            if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                                args.parentNode.replaceChild(editorArgs, args);
                            else
                            {
                                var cloned = args.cloneNode(true);
                                var div = args.ownerDocument.createElement("DIV");
                                div.appendChild(cloned);
                                editorArgs.pasteHtml(div.innerHTML);
                            }
                       }
                       editor.showExternalDialog(
                       '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/LinksDialog.aspx") %>',
                       editorArgs, 
                       750, 
                       600, 
                       myCallbackFunction, 
                       null, 
                       'ImageLibraryDialog', 
                       false, 
                       Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
                       false, 
                       true)
                    };
      
                    Telerik.Web.UI.Editor.CommandList["SetLinkProperties"] = function(commandName, editor, args)
                    {
                       var editorArgs = editor.getSelectedElement();
                       if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                            editorArgs = editor.getSelection();
                         
                       var myCallbackFunction = function(sender, args)
                       {
                            if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                                args.parentNode.replaceChild(editorArgs, args);
                            else
                            {
                                var cloned = args.cloneNode(true);
                                var div = args.ownerDocument.createElement("DIV");
                                div.appendChild(cloned);
                                editorArgs.pasteHtml(div.innerHTML);
                            }
                       }
                       editor.showExternalDialog(
                       '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/LinksDialog.aspx") %>',
                       editorArgs, 
                       750, 
                       600, 
                       myCallbackFunction, 
                       null, 
                       'ImageLibraryDialog', 
                       false, 
                       Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
                       false, 
                       true)
                    };
                    var oldFunction = Telerik.Web.UI.Editor.CommandList["ToggleScreenMode"]; //save the original Paste function
      
                    Telerik.Web.UI.Editor.CommandList["ToggleScreenMode"] = function(commandName, editor, args)
                    {
                        oldFunction(commandName, editor, args);
                        var bd = document.getElementsByTagName("body")[0];
                          
                        if(/fullScreenMode/.test(bd.className)) {
                            var rep = bd.className.match(' '+'fullScreenMode')?' '+'fullScreenMode':'fullScreenMode';
                            bd.className=bd.className.replace(rep,'');
      
                        } else {
                            bd.className += bd.className?' '+'fullScreenMode':'fullScreenMode';
                        }
                    };
                      
                    // automated tests helper function
                    function InsertTextArea()
                    
                        var editor = $find('<%=Editor.ClientID%>');
                        editor.set_html('<textarea id="myTableToFind" style="overflow:hidden; height: 300px; width: 500px;" border="none"></textarea>'); 
                    }
                      
                    </script>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Editor" Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True" ValidationGroup="InsertNews"><strong><asp:Literal ID="Literal6" runat="server" Text="<%$Resources:ContentEmpty %>"></asp:Literal></strong></asp:RequiredFieldValidator>                            
                </div>
        </fieldset>
        <div class="bottom"><div><!-- --></div></div>
        <sf:ContentMetaFields ID="MetaFields" runat="server">
            <ItemTemplate>
                <h3><asp:Literal ID="Literal7" runat="server" Text="<%$Resources:Category %>"></asp:Literal></h3>
                 <fieldset class="set">
                    <ol class="setIn">
                        <li class="catSel clearfix">
                                <asp:Label ID="Label8" AssociatedControlID="Category" runat="server">
                                    <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:Category %>"></asp:Literal>
                                <em id="Em1" runat="server"></em></asp:Label>
                                <sf:ContentCategoriesField ID="Category" runat="server" />
                         </li>                                                 
                        </ol>
                    </fieldset>
                    <div class="bottom"><div><!-- --></div></div>
                    <h3>
                        <asp:Literal ID="Literal3" runat="server" Text="<%$Resources:Tags %>"></asp:Literal></h3>
                    <fieldset class="set">
                        <ol class="setIn">
                            <li class="tags">
                                <sf:ContentTagEditor ID="tagsControl" runat="server" />
                            </li>
                        </ol>
                    </fieldset>
                    <div class="bottom">
                        <div>
                            <!-- -->
                        </div>
                    </div>
                    <h3><asp:Literal ID="Literal8" runat="server" Text="<%$Resources:AdditionalInfo %>"></asp:Literal></h3>
                    <fieldset class="set">
                      <ol class="setIn">
                        <li>
                            <asp:Label ID="Label4" AssociatedControlID="Summary" runat="server"><asp:Literal ID="Literal6" runat="server" Text="<%$Resources:Summary %>"></asp:Literal> <em id="SummaryLabel" runat="server"></em></asp:Label>
                            <asp:TextBox ID="Summary" TextMode="MultiLine" Text="" runat="server"></asp:TextBox>
                            <p class="example"><asp:Literal ID="Literal9" runat="server" Text="<%$Resources:SummaryNote %>"></asp:Literal></p>
                        </li
                         <li>
                            <asp:Label ID="Label3" AssociatedControlID="Author" runat="server"><asp:Literal ID="Literal10" runat="server" Text="<%$Resources:Author %>"></asp:Literal> <em id="AuthorLabel" runat="server"></em></asp:Label>
                            <asp:TextBox ID="Author" Text="<%$Resources:AuthorInput %>" runat="server" MaxLength="250"></asp:TextBox>
                            <p class="example"><asp:Literal ID="Literal11" runat="server" Text="<%$Resources:AuthorNote %>"></asp:Literal></p>
                        </li>
                         <li>
                            <asp:Label ID="Label5" AssociatedControlID="Source" runat="server"><asp:Literal ID="Literal12" runat="server" Text="<%$Resources:Source %>"></asp:Literal> <em id="SourceLabel" runat="server"></em></asp:Label>
                            <asp:TextBox ID="Source" Text="" runat="server" MaxLength="250"></asp:TextBox>
                            <p class="example"><asp:Literal ID="Literal13" runat="server" Text="<%$Resources:SourceNote %>"></asp:Literal></p>
                        </li>
                        <li class="selector">
                            <asp:Label ID="Label2" AssociatedControlID="Thumbnail" runat="server"><asp:Literal ID="Literal14" runat="server" Text="<%$Resources:Thumbnail %>"></asp:Literal> <em id="ThumbnailLabel" runat="server"></em></asp:Label>
                            <asp:TextBox ID="Thumbnail" Text="" runat="server" MaxLength="250"></asp:TextBox>
                            <sfLib:ButtonSelector WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx" ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx" AssociatedControls="Thumbnail" runat="server" cssclass="pickerWrapper" ButtonText="<%$Resources:Select%>" />
                            <p class="example">
                                <asp:Literal ID="Literal15" runat="server" Text="<%$Resources:ThumbnailNote %>"></asp:Literal>
                            </p>
                        </li>
                      </ol>  
                    </fieldset>
                    <div class="bottom"><div><!-- --></div></div>
                      
                      
                      
                      
                    <h3><asp:Literal ID="Literal16" runat="server" Text="<%$Resources:Schedule %>"></asp:Literal></h3>
                    <fieldset class="set dates">
                        <ol class="setIn">                               
                          
                         <li>
                            <asp:Label ID="Label6" AssociatedControlID="Publication_Date" runat="server"><asp:Literal ID="Literal17" runat="server" Text="<%$Resources:PublicationDate %>"></asp:Literal> <em id="Publication_DateLabel" runat="server"></em></asp:Label>                                    
                            <telerik:RadDateTimePicker ID="Publication_Date" runat="server"></telerik:RadDateTimePicker>
                        </li>
                        <li>
                            <asp:Label ID="Label7" AssociatedControlID="Expiration_Date" runat="server"><asp:Literal ID="Literal18" runat="server" Text="<%$Resources:ExpirationDate %>"></asp:Literal> <em id="Expiration_DateLabel" runat="server"></em></asp:Label>                                    
                            <telerik:RadDateTimePicker ID="Expiration_Date" runat="server"></telerik:RadDateTimePicker>
                        </li>                                 
                    </ol>
                </fieldset>
                     <h3><asp:Label ID="Label11"  Text="Reporters" runat="server"></asp:Label>
                                        </h3>
                            <fieldset class="set">
                                <ol class="setIn">
                                  
                                <li>  
                                    <asp:DropDownList ID="Reporter" runat="server"   />
      
                                 </li>  
      
      
                                  
                                  
                                </ol>
                                  
            </ItemTemplate>
        </sf:ContentMetaFields>
        <div class="bottom"><div><!-- --></div></div>
        <p class="button_area">
            <asp:LinkButton ID="saveButton1" runat="server" CssClass="CmsButLeft okdark" ValidationGroup="InsertNews" Text="<%$Resources:CreateThisNewsItem %>" />
            <asp:Label ID="Literal20" runat="server" Text="<%$Resources:Or %>" />
            <asp:LinkButton ID="cancelButton1" Text="<%$Resources:Cancel %>" runat="server" CssClass="cmscclcmd" causesvalidation="false" />
        </p>
        </div>
        <div class="info" id="divFaq" runat="server">
        <div class="infoBottom">
            <h3><asp:Literal ID="Literal22" runat="server" Text="<%$Resources:NewsFAQ %>"></asp:Literal></h3>
            <asp:Literal ID="Literal23" runat="server" Text="<%$Resources:NewsFAQText %>"></asp:Literal>
            <p class="hideAllFAQs">
                <a href="javascript:void(0)" onclick="javascript:Personalization.hideFaqSection('<%= divFaq.ClientID %>')">Hide FAQs everywhere</a>
            </p>
            </div>
        </div>
        <div class="clear"><!-- --></div>
    </div>
    NewsItemNew.ascx.cs

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Telerik.News.WebControls;
    using Telerik.Cms.Web;
    using Telerik.Cms.Engine;
    using Telerik.Cms.Engine.ContentViewFiltering;
    using System.Collections;
    using System.Text;
    using System.Collections.Generic;
    using DeepBlueCore;
    using Telerik.News;
      
      
    public partial class Sitefinity_Admin_ControlTemplates_News_NewsItemNew : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GetContentByCategory();
            GetPostByID();
        }
      
      
        private void GetContentByCategory()
        {
            DropDownList ddlContent = new DropDownList();
            DropDownList Reporter = FindControlRecursive(MetaFields, "Reporter") as DropDownList;
      
            Reporter.Items.Add(new ListItem("Select a reporter", ""));
      
            Guid categoryGuid = new Guid("10938861-201b-42d7-86bf-c59d471d037f");
      
            // create new instance of ContentManager
            Telerik.Cms.Engine.ContentManager contentManager = new Telerik.Cms.Engine.ContentManager();
      
            // create list that contains filters
            List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>();
            // add a new filter to the list
            filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Category", "reporters", Telerik.Cms.Engine.SearchCondition.Equal));
            // get content items filtered by specified filters
            IList listOfContentItems = contentManager.GetContent(filter.ToArray());
      
            if (listOfContentItems.Count > 0)
            {
                //IList IContent = listOfContentItems;
                //ddlContent.DataSource = IContent;
      
                foreach (IContent iContent in listOfContentItems)
                {
                    Reporter.Items.Add(new ListItem(iContent.GetMetaData("Name").ToString(), iContent.ID.ToString()));
                }
            }
        }
      
        private Control FindControlRecursive(Control root, string id)
        {
            if (root.ID == id)
            {
                return root;
            }
      
            foreach (Control c in root.Controls)
            {
                Control t = FindControlRecursive(c, id);
                if (t != null)
                {
                    return t;
                }
            }
      
            return null;
        }
      
        #region[Post]
        private void GetPostByID()
        {
            Telerik.News.NewsManager manager = new Telerik.News.NewsManager("News");
            IList listOfAllNews = manager.GetNews();
            Guid selectedPostGuid = new Guid();
      
            DropDownList Reporter = FindControlRecursive(MetaFields, "Reporter") as DropDownList;
      
            foreach (INews NewsItem in listOfAllNews)
            {
                Guid parentId = NewsItem.ID;
                IList allposts = manager.GetPosts(string.Empty, NewsItem.ID, NewsItem.ID);
      
                selectedPostGuid = new Guid(Common.QueryString("Param"));
      
                foreach (IContent post in allposts)
                {
                    if (post.ID == selectedPostGuid)
                    {
                        Reporter.SelectedValue = (string)post.GetMetaData("Reporter");
                        break;
                    }
                }
      
            }
        }
        #endregion
      
      
    }
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Sep 2010
    Link to this post
    Hi Steven Lancaster,

    Each news item (IContent) should have a custom metkey where you type the Author.

    1. Getting items for a given  Reporter - all stories done by that reporter

    Here you can use metaserch filter

    sample

    var contentManager = new Telerik.Cms.Engine.ContentManager("News");
    List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>();
     
    filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Reporter", "NameofReporter"));
    // get content items filtered by specified filters
    IList listOfContentItems = contentManager.GetContent(filter.ToArray());
    if (listOfContentItems.Count > 0)
    {
       foreach (Telerik.Cms.Engine.IContent contentItem in listOfContentItems)
           Response.Write("<br />" + contentItem.GetMetaData("Title") + "<br />");
    }

    If you want to search for more than one author at the same time you have to add an extra filter. If there are more than one reporters for a given story you should have a convention about entering the names of the reporters - for instance separat/split them by ",". Then you will get the metadata string and split the reported.

    var s = "Reporter1,Reporter2";
    var result = s.Split(',');

    After that just create an extra filter as mentioned above.

    2. Getting Reporter name by News item( title or another parameter)- you have item/s and you want to get the Reporter/s.

    You need to get all content items and loop through them. You can use C# indexer and return list of Reporters

    sample

    var nameofitem = "News item title";
     var cntManager = new ContentManager("News");
     List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>();
     filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Name", nameofitem ));
     
    var cntList  = cntManager.GetContent(filter.ToArray());
    foreach (IContent c in cntList)
    {
        var reporter = c.GetMetaData("Reporter");
    }

    Title and name are not a good identifiers and you have to use ID .


    All the best,
    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
5 posts, 0 answered