Display various language versions of a page in a NewsList

Hello, I would like to use the NewsList control where each of the Items iterated will display the language versions available for each of the items. It will look something like this. ---------------------------------------------- PageName Also available in: English French Spanish ---------------------------------------------- PageName Also available in: English French Spanish ---------------------------------------------- PageName Also available in: English French Spanish ---------------------------------------------- This is a similar request as the one in: http://www.episerver.com/en/EPiServer_Knowledge_Center/Developer-Forum2/EPiServer-Developer-Forums-/1805/14366/ I've tried the following but it's not working: ASPX " title="<%#container.previewtext%>"> <%#container.currentpage.pagename%> <%#languageversion(container.currentpage)%> <%--><%=stravailable %>--%> Also available in: <%#container.currentpage.pagename %> <%--><%# getlanguagedisplayname(container.currentpage.languagebranch) %>--%>   CS public PageDataCollection pagesWithPdfLinks = new PageDataCollection(); public PageDataCollection langVersions; public string LanguageVersion(PageData pd) { string _languageName; // Only brain compiled - put it into PageLoad langVersions = Global.EPDataFactory.GetLanguageBranches(pd.PageLink); foreach (PageData page in langVersions) { pagesWithPdfLinks.Add(page); } lstPdfLinks.DataSource = pagesWithPdfLinks; lstPdfLinks.DataBind(); return pd.PageName; }
Nov 29, 2007 16:55
Hi, this is almost the same solution as the other one, just a few subtle differences. First the list. Make sure you databind this in your page load. <%#Container.CurrentPage.PageName%> <%-- The Trick is to feed this list with the correct PageDataCollection --%>
Also available in:
<%# GetLanguageDisplayName(Container.CurrentPage.LanguageBranch) %>  

The inner list will query for it's own page data collection based on the current page. But to get this list, we create a method in the code behind file to gather the data. You already have the GetLanguageDisplayName() method, so the only additional one you need is this: // This is practically the same code as in the previous thread, but // put into its own method so we can reuse it. public PageDataCollection GetLanguageVersions(PageData currentPage) { PageDataCollection langVersions = Global.EPDataFactory.GetLanguageBranches(currentPage.PageLink); PageDataCollection pagesWithPdfLinks = new PageDataCollection(); foreach (PageData page in langVersions) { // Check that it is not the same lang as the currently loaded one // Also check that the page has a value for the pdf link if (currentPage.LanguageBranch != page.LanguageBranch && page["varFilePath"] != null) { // We have a language version of the page pagesWithPdfLinks.Add(page); } } // That's it - return it return pagesWithPdfLinks; }
Nov 29, 2007 22:52
Thank you so much Steve. You're great!
Nov 30, 2007 9:29
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.