More in this section

Forums / Developing with Sitefinity / Linking a list item

Linking a list item

2 posts, 0 answered
  1. Richard
    Richard avatar
    77 posts
    Registered:
    24 Oct 2007
    09 Jun 2010
    Link to this post
    Hello,

    I've created a list using the Lists modules, and have added some items in to that list.  Does anyone know how I can link directly to a list item so I can create shortcuts in my pages?  At the moment, when I click on any list item, the url does not change away from the url of the list.

    Thanks
    R
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    09 Jun 2010
    Link to this post
    Hi Richard,

    It could be done. You have to create a custom control that inherits from ListDisplay. Then override PageLists_ItemCreated and implement a custom method that will show a single item based on the ID of a single item in the QueryString

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Lists.WebControls;
    using Telerik.Lists;
    using System.Web.UI;
      
    /// <summary>
    /// Summary description for ListsDisplayCustom
    /// </summary>
    public class ListsDisplayCustom :ListDisplay
    {
        public ListsDisplayCustom()
        {
            //
            // TODO: Add constructor logic here
            //
        }
      
        protected override void PageLists_ItemCreated(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
      
            if (!String.IsNullOrEmpty(Context.Request.QueryString["item"]))
            {
                var qs = Context.Request.QueryString["item"];
                ShowSingleItem(qs);
      
            }
            else
            {
                base.PageLists_ItemCreated(sender, e);
            }
        }
      
        public virtual void ShowSingleItem(string id)
        {
            IListItem listItem = (IListItem)this.Manager.GetListItem(new Guid(id));
            if (this.PageListContainer.Headline != null)
            {
                ((Control)this.PageListContainer.Headline).Visible = true;
                this.PageListContainer.Headline.Text = listItem.Headline;
            }
      
            if (this.PageListContainer.Content != null)
            {
                ((Control)this.PageListContainer.Content).Visible = true;
                this.PageListContainer.Content.Text = "" // get the list item content here
            }
      
            if (this.PageListContainer.BackToAllItemsButton != null)
                ((Control)this.PageListContainer.BackToAllItemsButton).Visible = true;
      
            this.PageListContainer.Lists.Visible = false;
        }
    }

    You have to add a ToolboxItem for the control and override PageListTemplatePath to set the path to your template.

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