More in this section

Forums / Developing with Sitefinity / Using a page control to filter news/articles - get parent page url

Using a page control to filter news/articles - get parent page url

2 posts, 0 answered
  1. Si
    Si avatar
    11 posts
    Registered:
    18 Nov 2011
    04 May 2012
    Link to this post
    Hello.  I wanted to implement the paging option on the news archive on my site, but when the archiver link is clicked for a specific month/year, the url passed picks up the current page "page" param in error.

    e.g.

    i have browsed to page 8 of news:
    http://localhost:22744/articles2?page=8 

    when i click on the SF archive control it takes me to:
    http://localhost:22744/articles2?page=8&year=2012&month=04 

    there is no page 8 for the records returned for year2012, month 04...so a 404 page occurs.  I raised a ticket and was told i needed build my own custom control to manage paging from archive control...

    So that is what i am trying to do, and i am nearly there, except i cannot build the URL properly for the hyperlinks in my archivelist.

    I have used a custom control to linq-to-object on

    using (NewsManager nMan = NewsManager.GetManager())

    and get back the yr, months and count... and its working, and passing in to a repeater, but my url always returns my usercontrol address in the project, not the parent page.

    e.g.

    http://localhost:22744/controls/archive/?page=1&year=2012&month=4 

    (my web user control is in /controls/archive)
    Not

    http://localhost:22744/articles2?page=1&year=2012&month=04  

    (articles2 is the page on which my page control has been dragged)

    Can anyone help me identify the correct c# to get the parent page url?

    I am currently using:
    string[] myUrl = this.Parent.Page.Request.Url.ToString().Split('?');<br>            NewurlStr = myUrl[0];


    to get url and strip out old page param, then building a hyperlink in my repeater

    myHref.NavigateUrl = string.Format("{0}?page=1&year={1}&month={2}", NewurlStr, myYM.yearMonth.Year, myYM.yearMonth.Month);<br>                myHref.Text = myYM.yearMonth.ToString("MMMM yyyy");<br>


    after researching i thought that  this.Parent.Page.Request.Url.ToString() would bring back the address but its isn't.

    i found this page:
    http://www.sitefinity.com/help/developer-manual/pages-interfaces.html 

    should I be using something from there to get back the correct detail?

    Many thanks in advance for your help,

    Simon

  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    08 May 2012
    Link to this post
    Hi,

    Get the current page that is currently requested in the browser trough SiteMapBase that has all the page nodes and resolved the one you currently browse.
    using Telerik.Sitefinity.Web;
      
     var actualSitemapNode = SiteMapBase.GetActualCurrentNode()


    All the best,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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