search
AI OnAI Off
A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More.
and when you enter EPiServer edit mode you see the SE, DK, NO and EN Flags.
//
Jörgen
protected void Application_Start(Object sender, EventArgs e)
{
EPiServer.Global.EPDataFactory.FinishedLoadingPage += new PageEventHandler(hideNonSupportedLanguageTabs);
EPiServer.Global.EPDataFactory.LoadedDefaultPageData += new PageEventHandler(hideNonSupportedLanguageTabs);
}
///
/// The invoking object
/// Parameters, e.g. the page
private static void hideNonSupportedLanguageTabs(object sender, PageEventArgs e)
{
string siteSupportedLanguages;
try
{
siteSupportedLanguages = EPiServer.Global.EPConfig["EPsLanguageSortOrder"].ToString();
for(int i = e.Page.Property.Count - 1 ; i >= 0 ; i-- )
{
PropertyData prop = e.Page.Property[i];
if (isSupportedLanguage(prop.Name, siteSupportedLanguages))
{
continue; // To next iteration
}
// Remove the property and replace it with itself after the name and tab i changed
e.Page.Property.Remove(prop.Name);
String newPropertyName = prop.Name.Replace("___", "__");
prop.OwnerTab = -1; prop.Name = newPropertyName;
e.Page.Property.Add(newPropertyName, prop);
}
}
catch(Exception ex)
{
}
}
///
/// The property name to test if it specifying a supported language
/// A comma-separated list of languages, each language described in two-letter abbreviation
///
private static bool isSupportedLanguage(string property, string supportedLanguages)
{
string languages = supportedLanguages.Replace(" ","")+ ",";
int separatorIndex = property.IndexOf(MultiLanguageRuntime.LANGUAGEPROPERTYSEPARATOR);
//Check if property is multilanguage compatible
if (separatorIndex >= 0)
{
string propLang = property.Substring(separatorIndex+MultiLanguageRuntime.LANGUAGEPROPERTYSEPARATOR.Length, 2);
if (languages.IndexOf(propLang + ",") >= 0)
{
return true;
}
}
else
{
//Property is not multilanguage, so should always be included
return true;
}
return false;
}
protected static NameValueCollection FindInstanceSettings(string project)
{
configEnum.Reset();
while(configEnum.MoveNext())
{
if(configEnum.Value.GetType().ToString() == "System.Collections.Specialized.NameValueCollection")
{
System.Collections.Specialized.NameValueCollection instance = configEnum.Value as System.Collections.Specialized.NameValueCollection;
if(Code.Common.GetString(instance["EPsProjectCode"]).ToUpper() == project)
{
return instance;
}
}
}
return null;
}
This method returns a NameValueCollection:
public void SomeMethod()
{
NameValueCollection instance = new NameValueCollection();
instance = FindInstanceSettings("Site1");
}
Frank :)
protected static Hashtable configurations;
protected static IDictionaryEnumerator configEnum;