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

Forums / Developing with Sitefinity / Find content by URL

Find content by URL

7 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    28 Sep 2010
    Link to this post
    Hello,

    I have a simplecontrol that im using to display one content item. To be able to display the single content item, i need to be able to match it by the URL. How can i do this?

    Thanks
    higgsy
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Sep 2010
    Link to this post
    Hello Alastair,

    IContent item has a property - UrlWithExtension that you can use. You might find this post useful getting your news articles full urls

    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
  3. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    28 Sep 2010
    Link to this post
    Hi Ivan,

    I dont think i explained myself very well.

    When i have a url like:

    /case-studies/single-article.aspx

    My simplecontrol doesnt know which content item to show, i.e. it hasnt yet mapped a content item to "single-article.aspx".

    Whereas a ContentView automatically sets the SelectedItemID, the SimpleControl doesnt, so i just need to know how i could essentially match a content item to the current url.

    Does that make miore sense.

    Thanks
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Sep 2010
    Link to this post
    Hi Alastair,

    ContentView has two modes - List and Detail. List mode displays all articles. Detail mode displays single item based on the content id passed through the url. The url format is set by content provider and it is formed depending on the metakeys set for this provider.

    Controls that inherits from SimpleControl have only one mode and this is List mode. Each content item has a metakeys collection from where you can get the title by using GetMetaData method.

    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. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    28 Sep 2010
    Link to this post
    Hi Ivan,

    Yes i understand that ContentView has two views. SimpleControl only has ListView, however surely SimpleControl could be used to simply display one piece of content by doing something like:

    IContent oContent = ContentManager.GetContent("/case-study-title.aspx")

    And then in InitializeControls just set the values of things such as literals to the metadata from oContent. 

    The reason im trying to do this is because i have developed a SimpleControl to display Case Studies in a tabbed format using nested repeaters. The page that shows the detail of each case study current uses a contentview, but there is no reason for it to do so because it will never show the listview.

    Does that make more sense.

    higgsy
  6. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    28 Sep 2010
    Link to this post
    Hi Ivan,

    Is there such a method that will allow me to match content based on the url??

    Thanks
    higgsy
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Sep 2010
    Link to this post
    Hello Alastair,

    You can create a custom method which returns IContent object with a single parameter where you pass the Title or UrlWithExtension and then loop through List of IContent objects.

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