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

Forums / Designing with Sitefinity / News View - singleItemUrl

News View - singleItemUrl

14 posts, 0 answered
  1. Zahid Ali
    Zahid Ali avatar
    47 posts
    Registered:
    16 Nov 2009
    10 Dec 2009
    Link to this post
    hi,

    the news view control works fine if I dont change singleItemUrl ( page specially prepared to hold single news info ).

    I created a page, and chose the page to display single news info but when i click read more I get the following error:

    Server Error in '/EnglandsEastMidlands' Application.

    The resource cannot be found.


    please advice why am I getting this 404 error.

    thanks.

    Zahid
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Dec 2009
    Link to this post
    Hello Zahid Ali,

    Make sure that on the page specially prepared to hold single news info you have NewsView control dropped.


    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Zahid Ali
    Zahid Ali avatar
    47 posts
    Registered:
    16 Nov 2009
    10 Dec 2009
    Link to this post
    uh - stupid mistake. thanks anyway!

    also, if i have a news view control but want the news to be filtered based on category the user selects from the dropdown - could i do this with user control or do i have to go down the api route?

    thanks.

    Zahid
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Dec 2009
    Link to this post
    Hi Zahid Ali,

    You can do it in user control using FilterExpression property of NewsView control. You can create the NewsView control dynamically or declaratively. Generally it is not a good approach to use CotentView based controls in a User Control.


    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Zahid Ali
    Zahid Ali avatar
    47 posts
    Registered:
    16 Nov 2009
    11 Dec 2009
    Link to this post
    Hi Ivan,

    Please excuse my ignorance. I din't quite understand: Generally it is not a good approach to use CotentView based controls in a User Control.

    Please clarify.

    thanks.

    Zahid
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Dec 2009
    Link to this post
    Hello Zahid Ali,

    There could be some problems when you add declaretively or dinamically ContentView based controls in a UserControl. It is better to inherit from the ContentView based control.


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Zahid Ali
    Zahid Ali avatar
    47 posts
    Registered:
    16 Nov 2009
    11 Dec 2009
    Link to this post
    Hi Ivan,

    To clarify, i thought NewsView does inherit from ContentView.

    Are you telling me that rather dragging user controla and playing with the properties from backend I should rather do like this:
     
    NewsView newsView = new NewsView();



    did i interpret your reply correctly?

    please advice.

    thanks.

    Zahid
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Dec 2009
    Link to this post
    Hello Zahid Ali,

    Below is a sample code that you can use in an user or custom control.

    NewsView newsView = new NewsView();
    ContentFilterBuilder filter = new ContentFilterBuilder(newsView);
    filter.AddFilter(new ContentFilterStatement("Category", "MyCategory", ContentFilter.Condition.Equal);


    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Zahid Ali
    Zahid Ali avatar
    47 posts
    Registered:
    16 Nov 2009
    11 Dec 2009
    Link to this post
    Hi Ivan,

    I'm having bit of difficulty adding the control to the page.

    I'm using the .Add() method - but it doesnt seem to work.

    Could you please point to an example that explains adding of the user control from code behind.

    thanks.

    Zahid
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Dec 2009
    Link to this post
    Hi Zahid Ali,

    Take a look at this article Control.ControlCollection.Add Method


    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  11. Zahid Ali
    Zahid Ali avatar
    47 posts
    Registered:
    16 Nov 2009
    11 Dec 2009
    Link to this post
    hi Ivan,

    Thanks for this - this is the same method i was working with but it was a wrong 'case' - huh!

    Now that I've got newsVIew filter working (thanks for the help), the value from RadComboBox when changed prints the correct value out on the page but the filter doesnt work until I click on a different page.

    please advice.

    thanks.

    Zahid
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Dec 2009
    Link to this post
    Hi Zahid Ali,

    I get back to your support request. Please check it out.


    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  13. Rehan
    Rehan avatar
    10 posts
    Registered:
    25 Nov 2009
    11 Feb 2010
    Link to this post
    Hi Ivan or Telerik,

    Sort of related to this post, however when using a ( page specially prepared to hold single news info ), i have all of this working perfectly fine, looks great and functions brilliantly.

    However if that custom page gets moved in terms of directory structure, SF does not update the URL from the newscontrol. I guess this is the same for Blogs also?

    Is there a reason for this using direct URL paths and not GUID's for the page selected using the SF "Select Page" function? If GUID was saved rather than direct URL Path, this would not effect the site if the page was moved.

    Also is the next release of SF going to get around this? Ideally if links have been created anywhere in the site, and page gets moved, the CMS user shouldnt need to worry about links to that page, like it does in the rest of the SF.
    If i've missed a trick here, appologies for the moan.

    Many thanks
    Rehan
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Feb 2010
    Link to this post
    Hi Rehan Butt,

    You are right. The page does not get updated because we do not use dynamic link there. We will consider changing the designer in the feature. The case is that there are some other relations that expects SingleItemUrl to be relative url, not a guid. Possible solution is creating a custom class that inherits from NewsView. Then you can override SingleItemUrl and resolve the url in the property. Then return the correct link.

    below is a sample implementation

    class CustomNewsView : NewsView
    {
     
        public override string ItemListTemplatePath
        {
            get { return "~/Sitefinity/ControlTemplates/News/ListPageMaster.ascx"; }
        }
     
        public override string SingleItemTemplatePath
        {
            get { return "~/Sitefinity/ControlTemplates/News/ListPageDetails.ascx"; }
        }
     
        [UrlProperty, WebEditor("Telerik.Cms.Web.UI.DhlUrlEditor, Telerik.Cms"), Bindable(true), Category("Navigation"), DefaultValue("")]
        public  string NavigateUrl
        {
            get
            {
                return this.navigateUrl;
            }
            set
            {
                this.navigateUrl = value;
            }
        }
        private string navigateUrl = String.Empty;
     
        [TypeConverter("Telerik.Cms.Web.UI.GuidTypeConverter, Telerik.Cms"), WebEditor("Telerik.Cms.Web.UI.DhlIdEditor, Telerik.Cms"), Category("Navigation"), DefaultValue(typeof(Guid), "00000000-0000-0000-0000-000000000000")]
        public Guid PageId
        {
            get
            {
                return this.pageId;
            }
            set
            {
                this.pageId = value;
            }
        }
        private Guid pageId;
     
        private string GetItemUrl(string val, bool resolveAsAbsoluteUrl)
        {
            if (val.StartsWith("~/"))
                return this.ResolveUrl(val);
     
            int idx = val.IndexOf("]");
     
            if (idx < 0)
            {
                return val;
            }
     
            string provider = val.Substring(1, idx - 1);
            string strId = val.Substring(idx + 1);
            Guid id = new Guid(strId);
     
            if (ContentManager.Providers.ContainsKey(provider))
            {
                IContent cnt = ContentManager.Providers[provider].GetContent(id);
                if (cnt != null)
                {
                    return VirtualPathUtility.ToAbsolute(cnt.UrlWithExtension, this.Context.Request.ApplicationPath);
                }
            }
            else
            {
                string url = CmsHelper.GetPageUrl(id, this.Context);
                if (!string.IsNullOrEmpty(url))
                {
                    return url;
                }
            }
            return String.Concat("Item not found: [", provider, "]", id);
        }
     
     
     
        protected override void CreateChildControls()
        {
            string text = GetItemUrl("[Sitefinity]"+ PageId.ToString(), true);
            this.SingleItemUrl = text;
            base.CreateChildControls();
        }
    }


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