More in this section

Forums / Developing with Sitefinity / Event detail link

Event detail link

12 posts, 0 answered
  1. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    14 Jul 2010
    Link to this post
    Hi all,

    I'm creating my own usercontrol for showing events.
    How should I create the link to a detailpage for an event?

    Is it possible to create a link with as a friendly URL? (like when you use the built-in views?)

    Daniel
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Jul 2010
    Link to this post
    Hello Daniel,

    You have to use QueryString keys where you append the ID of the content item. Another option is using Session, Cookie or ViewState. We use QueryString parameters and the url is rewritten by ContentUrlRewriterService and ContentUrlRewriteData

    Sincerely yours,
    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. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    14 Jul 2010
    Link to this post
    Thanks Ivan.
    Is there documentation or an example on how to use the ContentUrlRewriterService and ContentUrlRewriteData?

    Thanks,
    Daniel
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Jul 2010
    Link to this post
    Hello Daniel,

    There is only API reference ContentUrlRewriterService Class


    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
  5. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    14 Jul 2010
    Link to this post
    I try to do it for some hyperlinks inside a repeater, but the method returns "".
    Probably the Provider isn't right. How can I get the right provider?

    protected void rptPosts_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            try
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    HyperLink lnkDetail = e.Item.FindControl("lnkDetail") as HyperLink;
                    IContent contentItem = (IContent)e.Item.DataItem;
      
                    string itemUrl = ContentUrlRewriterService.FormatURL(contentItem, ContentManager.Providers[contentItem.ProviderName], ContentUrlRewriterService.FormatOptions.QueryString);
                    lnkDetail.NavigateUrl = itemUrl;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

    Thanks,
    Daniel
  6. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    14 Jul 2010
    Link to this post
    Hmm... okay, I figured that one out.
    Anyway, it generates a nice link like this:

    /evangelischegemeente/activities/calendar/10-07-13/mainevent.aspx

    Now the problem is when you navigate to it, it shows an error that page doesn't exist. What should be the way to create a detail page that actually listens to such url?

    Daniel
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Jul 2010
    Link to this post
    Hello Daniel,

    Read the item ID from the url.  Call GetContent() of ContentManager. Loop through IContent properties and set some values to details mode of your control. The easiest way is to have one template with two holders - master holder and details holder. If the ID exists as a QueryString in the url, hide master holder and repeater control that lists all items and show details holder and all controls inside it.

    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
  8. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    14 Jul 2010
    Link to this post
    Hi Ivan,

    I don't get it.
    This is a friendly url, so the ID is not shown here.

    This is the main url which holds a list with 'Events'
    http://192.168.90.28/evangelischegemeente/activiteiten/agenda.aspx

    Each item in this list should navigate to a detail page, or show the detail placeholder as you mentioned before.
    The link that is generated looks like this:

    http://192.168.90.28/evangelischegemeente/activities/calendar/10-07-13/event.aspx

    If you navigate to it, SF expects this page?

    I tried this method on the Page_Load, but it goes wrong because it is a link, so it navigates away from the page so it never fires.

    IContent item = ContentUrlRewriterService.Instance.GetContentItem(Request.Path) as IContent;

    Regards,
    Daniel
  9. Shawn
    Shawn avatar
    79 posts
    Registered:
    01 Jun 2010
    15 Jul 2010
    Link to this post
    Hi Dan,

    I'm a little confused.  Are you trying to customize the URL of events?  Or are you just trying to write a custom view for displaying events? 

    If it's the first scenario have you explored modifying the default URL re-writing rule in the web.config.  There is also a webinar that helped clarify url re-writing for me. http://www.sitefinity.com/devnet/webinars/url-rewriting-in-sitefinity.aspx.

    If it's the second scenario, can you just use the default Event control implementation and create a new view template (see image below) and set the "SingleItemTemplatePath"?  You could also create your own control that inherits from the base event control and override the single item template path.  This is a little easier for end users.

    I'm probably not understanding your question...but I hope this helps.
  10. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    15 Jul 2010
    Link to this post
    Hi Shawn,

    Yes, I'm using a custom UserControl to display events. From this list with events I want to link to a detail page. I'm getting that done using a normal querystring like:

    http://www.mydomain.com/events/detail.aspx?id=4949-3232 ...

    But I want this url to be friendly.

    I didn't inherit from Event, maybe that will do the trick?
    I'll let you know how it goes.

    Thanks for your reply,
    Daniel
  11. Shawn
    Shawn avatar
    79 posts
    Registered:
    01 Jun 2010
    15 Jul 2010
    Link to this post
    Hi Dan,

    I gave you the wrong information.  You would want to override the ItemListTemplatePath...not the SingleItemTemplatePath.  I would create a user control that inherits from the Events view control (not sure the class name) and just override the ItemListTemplatePath.  Then I would take a look at the existing list item template. You can download it from http://www.sitefinity.com/account/free-trials/trial-product-versions/single-trial.aspx?pmvid=2183&pid=0 if you haven't already.  Hope this works.
  12. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    15 Jul 2010
    Link to this post
    Yes, I have looked into that, but because my view has some very specific styling, I was not able to get it done. I use my own provider for Event items (calendar items).

    So, I tried to adjust the Telerik.Sitefinity.Configuration.ControlsConfig.xml to add additional views for my Event provider, but for events it works a little different.

    Anyway, I thought I will build this view from scratch, using a normal ASP.NET UserControl, which shows my events correctly (different paging, sorting etc.). Then I create another UserControl to show the details of an event.
    I can sure make this, but then it doesn't use this friendly urls...

    Daniel
Register for webinar
12 posts, 0 answered