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

Forums / Developing with Sitefinity / Customizing server-side hyperlinks in templates

Customizing server-side hyperlinks in templates

6 posts, 0 answered
  1. Michael Park
    Michael Park avatar
    13 posts
    Registered:
    23 Oct 2009
    19 Nov 2009
    Link to this post
    I'm trying to append my own custom querystring variable to a hyperlink on the Events ListPageMaster.ascx and was wondering how I would extend or override the setting of that link.  For example in the following

         <h3 class='sf_eventTitle'>

                    <asp:HyperLink ID="fullContent1" runat="server">

                        <asp:Literal ID="Title" runat="server" />

                    </asp:HyperLink>

                </h3>


    I would want to append a querystring parameter to pass the Page.Theme in the view more link.  I don't want to generate my own hyperlink since Sitefinity already generates the view more url path.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Nov 2009
    Link to this post
    Hello Michael Park,

    You need to create a custom control that inherits from Events. Then you can override SetItemContent and access the Hyperlink control. Afterwords you can modify its NavigateUrl property

    sample

    public class CustomEventsView : EventsView
    {
        public CustomEventsView()
        {
      
        }
      
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/Admin/ControlTemplates/Events/Design/ListPageMaster.ascx";
            }
      
        }
      
        public override string SingleItemTemplatePath
        {
            get
            {
                return "~/Sitefinity/Admin/ControlTemplates/Events/Design/ListPageDetail.ascx";
            }
              
        }
      
        protected override void SetItemContent(Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
        {
            base.SetItemContent(itemContainer, contentItem);
            for (int i = 1; i < 6; i++)
            {
                Control ctrl = FindContentViewControl("fullContent" + i, itemContainer);
                if (ctrl is HyperLink)
                {
                    // do something
                }
            }
        }
    }

    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.
  3. Michael Park
    Michael Park avatar
    13 posts
    Registered:
    23 Oct 2009
    19 Nov 2009
    Link to this post
    Is there a function or method that lets me get the event item's detail url path?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Nov 2009
    Link to this post
    Hi Michael Park,

    You can use contentItem.UrlWithExtension or take a look at Getting your News articles full Urls ( the same applies for all ContentView based controls)-

    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. Michael Park
    Michael Park avatar
    13 posts
    Registered:
    23 Oct 2009
    19 Nov 2009
    Link to this post
    After I create the custom control class, how do I map it so that it's used?  In the EventsViewControlDesigner I can set templatepaths but not sure how to get events to use my eventview class.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Nov 2009
    Link to this post
    Hi Michael Park,

    When you create the custom class you can register it in your web.config file <toolboxControls> section. Since you are inheriting from EventsView your control will use all the base functionality until you make some changes.

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