SharePoint Theme | File Not Found Error
Most "File not found" errors on "Activating" themes are due to "SPTHEMES.XML " file location not found.
This happens because languages on websites may differ:
ENG - @TEMPLATE\LAYOUTS\1033\SPThemes.xml
PTG - @TEMPLATE\LAYOUTS\2070\SPThemes.xml
The best way to fix this is by calling your SPTHEMES.XML XML Editor Method with the current web language as Theme List folder.
Then, if the language folder named after the current website language cannot be found, it means that the user has changed the regional settings to another language, but he does NOT have installed a language pack for that language (LCID folder).
So, we go on installing on English (LCID 1033) folder.
If both of them fail (for crash prevention) we give up on applying the theme.
using System.Globalization;
(...)
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPWeb web = (SPWeb)properties.Feature.Parent)
{
string LCID = web.Language.ToString(CultureInfo.InvariantCulture);
string spfile = test_spthemes_folder(LCID);
if(spfile!="none")
//change xml and update web
}
}
(...)
string test_spthemes_folder(string LCID)
{
//do not choose 1033 as default,
//first search for SPTHEMES in current language folder
string languagepath = @"TEMPLATE\LAYOUTS\" + LCID;
string englishpath = @"TEMPLATE\LAYOUTS\1033";
string spthemePath = "";
//current language file does not exist
if (!File.Exists(Path.Combine(SPUtility.GetGenericSetupPath(languagepath), "SPTHEMES.XML")))
{
//1033 language folder does not exist... give up
if (!File.Exists(Path.Combine(SPUtility.GetGenericSetupPath(englishpath), "SPTHEMES.XML")))
{
return "none"; //cannot find SPTHEMES.XML
}
else
{
//file found in 1033 folder
spthemePath = Path.Combine(SPUtility.GetGenericSetupPath(englishpath), "SPTHEMES.XML");
}
}
else
{
//file found in current language folder
spthemePath = Path.Combine(SPUtility.GetGenericSetupPath(languagepath), "SPTHEMES.XML");
}
//continue with changing SPTHEMES.XML
return spthemePath ;
}
This happens because languages on websites may differ:
ENG - @TEMPLATE\LAYOUTS\1033\SPThemes.xml
PTG - @TEMPLATE\LAYOUTS\2070\SPThemes.xml
The best way to fix this is by calling your SPTHEMES.XML XML Editor Method with the current web language as Theme List folder.
Then, if the language folder named after the current website language cannot be found, it means that the user has changed the regional settings to another language, but he does NOT have installed a language pack for that language (LCID folder).
So, we go on installing on English (LCID 1033) folder.
If both of them fail (for crash prevention) we give up on applying the theme.
using System.Globalization;
(...)
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPWeb web = (SPWeb)properties.Feature.Parent)
{
string LCID = web.Language.ToString(CultureInfo.InvariantCulture);
string spfile = test_spthemes_folder(LCID);
if(spfile!="none")
//change xml and update web
}
}
(...)
string test_spthemes_folder(string LCID)
{
//do not choose 1033 as default,
//first search for SPTHEMES in current language folder
string languagepath = @"TEMPLATE\LAYOUTS\" + LCID;
string englishpath = @"TEMPLATE\LAYOUTS\1033";
string spthemePath = "";
//current language file does not exist
if (!File.Exists(Path.Combine(SPUtility.GetGenericSetupPath(languagepath), "SPTHEMES.XML")))
{
//1033 language folder does not exist... give up
if (!File.Exists(Path.Combine(SPUtility.GetGenericSetupPath(englishpath), "SPTHEMES.XML")))
{
return "none"; //cannot find SPTHEMES.XML
}
else
{
//file found in 1033 folder
spthemePath = Path.Combine(SPUtility.GetGenericSetupPath(englishpath), "SPTHEMES.XML");
}
}
else
{
//file found in current language folder
spthemePath = Path.Combine(SPUtility.GetGenericSetupPath(languagepath), "SPTHEMES.XML");
}
//continue with changing SPTHEMES.XML
return spthemePath ;
}
Comments
Post a Comment