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

Posted by Community Admin on 04-Aug-2018 12:25

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

All Replies

Posted by Community Admin on 04-May-2012 00:00

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

Posted by Community Admin on 08-May-2012 00:00

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

This thread is closed