November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
// Only brain compiled - put it into PageLoad
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);
}
}
lstPdfLinks.DataSource = pagesWithPdfLinks;
lstPdfLinks.DataBind();
Now you have a collection of page language versions that have a value for the pdf link. It does not contain the currently showing language version. It has been bound to a PageList control, which could look like this:
Also available in:
]]>
and you need the GetLanguageDisplayName method in your code behind file:
protected string GetLanguageDisplayName(string languageBranch)
{
return LanguageBranch.Load(languageBranch).Name;
}
I think this should do the trick, at least it should give you some pointers on how to solve it.
/Steve
]]>" runat="server">
<%#ContainerPage(Container.CurrentPage)%>
<%----%>
<%# GetLanguageDisplayName(Container.CurrentPage.LanguageBranch) %>
<%----%>
And the following in the cs:
public PageDataCollection pagesWithPdfLinks = new PageDataCollection();
public PageDataCollection langVersions;
protected EPiServer.WebControls.PageList lstPdfLinks;
public void ContainerPage(PageData pr)
{
langVersions = Global.EPDataFactory.GetLanguageBranches(pr.PageLink);
foreach (PageData page in langVersions)
{
// We have a language version of the page
pagesWithPdfLinks.Add(page);
}
lstPdfLinks.DataSource = pagesWithPdfLinks;
lstPdfLinks.DataBind();
}
protected static string GetLanguageDisplayName(string languageBranch)
{
if (LanguageBranch.Load(languageBranch).Name == "Default")
return "English";
else
return LanguageBranch.Load(languageBranch).Name;
}
Needless to say, it doesn't work as smoothly as the one you suggested.
Any advice?
public string GetPDFLink() { //private PageData langPage; This is declared elsewhere. LanguageBranch lb = LanguageBranch.Load(DocumentPage.LanguageBranch); string _getPDFLink = ""; if (lb.Name == "Default") { _getPDFLink = (string)DocumentPage["varFilePath"]; } else if (lb.Name == "FR") { EPiServer.Core.LanguageSelector selectorFR = new EPiServer.Core.LanguageSelector("FR"); langPage = EPiServer.Global.EPDataFactory.GetPage(DocumentPage.PageLink, selectorFR); _getPDFLink = (string)langPage["varFilePath"]; // This should be the value from the French version of the page } else if (lb.Name == "ES") { EPiServer.Core.LanguageSelector selectorES = new EPiServer.Core.LanguageSelector("ES"); langPage = EPiServer.Global.EPDataFactory.GetPage(DocumentPage.PageLink, selectorES); _getPDFLink = (string)langPage["varFilePath"]; // This should be the value from the Spanish version of the page } return _getPDFLink; }