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

Forums / General Discussions / Sorting control over ContentView

Sorting control over ContentView

8 posts, 0 answered
  1. Johnny
    Johnny avatar
    45 posts
    Registered:
    08 Mar 2009
    15 Sep 2010
    Link to this post
    Hi,

    Is there a way to have some more control over the sorting order in the generic content view control? I know that I can sort by the meta fields and perhaps I need to have additional meta fields to have better control over the order in witch the content is displayed. Can I have a some sort of "sort order" meta field? Is that a good solution or is their some other alternatives that are better?

    I have also tried to have multiple content view controls on a page and sort thoose with different categories to get the desired functionality. The problem with that is that when I click to read the full article, the article is shown in all my content views. Is their a way around this?

    /Johnny
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Sep 2010
    Link to this post
    Hello Johnny,

    Using additional metakey is the easiest way and it does not require coding. You can create as many metakeys and use filtering or sorting option only from the UI.

    Some complex solution will require to override the control and its CreateDataSource where you will return a filtered list based on a criteria. In this case you can use LINQ or Comparer for sorting/filtering, database queries

    The issue you have does not anything to do with filtering or sorting. The problem here is that - ContentView based controls uses QueryString key to rewrite the url( this key is not visible, because we internally rewrite the url) It can be easily fixed by changing

    ContentItemKeyPersistance and ContentItemKey properties of the control (Advances Tab >> QueryString keys), so that the values for ContentItemKey in both the controls will be different.
    ContentItemKeyPersistance should be set to QueryString.



    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
  3. Johnny
    Johnny avatar
    45 posts
    Registered:
    08 Mar 2009
    15 Sep 2010
    Link to this post
    Additional meta keys will work fine. Perhaps I should have started with the news provider instead of the GC provider :)

    As for my other question. I tried to change the ContentItemKeyPersistance to QueryString in each and every one of my content view controls on the page. However if I click on full story on one of the items, that item is shown on the other three content views as well in full story mode. This is also the case when you have multiple content items with the same category, in the one content view. Is there some other configuration that I need to do?

    /Johnny
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Sep 2010
    Link to this post
    Hi Johnny,

    When ContentItemKeyPersistance and ContentItemKey properties of the control are set up as described, the control behaves as attached video shows.

    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
  5. Johnny
    Johnny avatar
    45 posts
    Registered:
    08 Mar 2009
    15 Sep 2010
    Link to this post
    Ok, besides that ContentItemKeyPersistance should be set to QueryString, what should the ContentItemKey be set to?

    Is it another way of achieving this so that one not have querystrings in the url? If I click the first content view, can I get that one in details mode and the rest of the contentviews stays in master mode?

    /Johnny
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Sep 2010
    Link to this post
    Hi Johnny,

    The value of ContentItemKey  does not matter. It should be different in these controls. Check one of the posts above to see why.

    If you do not want to use QueryString you have to override the control behavior by creating a custom class that inherits from ContentView. Override SetItemMetadata and subscribe for Click event of fullContent+i Hyperlink which can be accessed from itemContainer which represents the Repeater control. Inside click event set item ID as a cookie that you should read in  CreateChildControls() method and show a single item based on this. Inside CreateChildControls you can filter the control by this value

    if (itemId != Guid.Empty && SingleModeSupported)
                 {
                     filterBuilder.AddFilter(new ContentFilterStatement("ID", itemId.ToString(),
                                                                        ContentFilter.Condition.Equal,
                                                                        ContentFilter.JoinType.And));
                     behaviorModeImpl = BehaviorModes.Detail;
                     CreateSingleContent();
                     Controls.Add(SingleContainer);
                 }



    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. Johnny
    Johnny avatar
    45 posts
    Registered:
    08 Mar 2009
    16 Sep 2010
    Link to this post
    How can I make this fit with a check to see if the user is logged in when he clicks on the full story link? I´m having big problems to make sure that the user get routed back to the article after he has click on full story and given credentials.

    Witch event handler should I hook up to? Would the SetSingleItemContent be obsolete?
    protected override void SetItemMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
        {
            base.SetItemMetadata(itemContainer, contentItem);
              
            for (int i = 1; i < 6; i++)
            {
                var ctrl = FindContentViewControl("fullContent1" + i, itemContainer);
                if (ctrl is HyperLink && Membership.GetUser(UserManager.GetCurrentUser()) != null)
                {
                    ((HyperLink)ctrl).NavigateUrl = contentItem.UrlWithExtension.ToString();
                }
      
                if (itemId != Guid.Empty && SingleModeSupported)
                {
                    filterBuilder.AddFilter(new ContentFilterStatement("ID", itemId.ToString(),
                                                                       ContentFilter.Condition.Equal,
                                                                       ContentFilter.JoinType.And));
                    behaviorModeImpl = BehaviorModes.Detail;
                    CreateSingleContent();
                    Controls.Add(SingleContainer);
                }
            }
        }
      
        protected override void SetSingleItemContent(Telerik.Cms.Engine.IContent item)
        {
            if (Page.User.Identity.IsAuthenticated)
            {
                base.SetSingleItemContent(item);
            }
            else
            {
                System.Web.HttpContext.Current.Response.Redirect("~/Login.aspx");
            }
        }
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Sep 2010
    Link to this post
    Hello Johnny,

    Routing with login is performed by ASP.NET Login control. You can force returning back to the destination page inside its LoggedIn event.

    voidLogin1_LoggedIn(objectsender, EventArgs e)
        {
            stringredirectUrl = Request.QueryString["ReturnUrl"];
            if(!string.IsNullOrEmpty(redirectUrl) && !redirectUrl.StartsWith(UrlHelper.PublicEntryPoint))
     
            {
                this.Response.Redirect(redirectUrl, true);
            }
     
        }


    SetSingleItemContent method is not obsolete and it is called inside CreateSingleContent

    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
8 posts, 0 answered