Programmatically get a specific page
Hello,
how can I programmatically get a "specific" page in my website?
Suppose that I have the "Events" page and I would like to programmatically get it. I have seen various ways to achieve this (in the documentation and in blog posts) but none of them are suitable for me:
Thank you!
Hi Luca,
You can get a specific page by its Title and then filter for the culture
var ci = System.Globalization.CultureInfo.GetCultureInfo(
"en"
);
var pageNodes = App.WorkWith()
.Pages()
.LocatedIn(PageLocation.Frontend)
.Where(p => p.Page.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && p.Title.Contains(
"Home"
))
.Get()
.AsQueryable();
var filteredTranslations = PageHelper.FilterPagesForLanguage(pageNodes, ci).AsQueryable();
Sorry but it's not an acceptable solution. Think to have a MultiLanguage site with 5 languages, a news list and a news detail. Now in news detail i need a link "All news". How can i get the url of that page knowing the title is "All news?
Hello,
If you know the title of the page you can simple query it and get the specified language url of the page.
Example:
PageManager manager =
new
PageManager();
var page = manager.GetPageNodes().Where(n => n.Title ==
"All News"
).SingleOrDefault();
var culture = System.Threading.Thread.CurrentThread.CurrentUICulture;
string
url =
string
.Empty;
if
(page !=
null
)
if
(page.AvailableCultures.Contains(culture))
url = page.GetUrl(
""
, culture,
true
);
else
url = page.GetUrl();
return
url;
Nice steps shared on this post that help users to get a specific page using programmatically. There are so many sources available that useful to get specific page but as per good source concern i would like to recommend one please check it here: www.facebook.com/HireMobileappsDevelopers from this source you can find the best mobile app developer that help you.