Issue
Read this blog ->
Sharepoint 2010 - Strange blog URL issue with site using Variations(Multilingual site). - REALLY WEIRD ISSUE!
Solution
#region System
using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.Administration;
using System.IO;
using System.Linq;
#endregion
namespace FeatureStapler.VariationBlogSiteEvent
{
/// <summary>
/// Web Events
/// </summary>
public class VariationBlogSiteEvent : SPWebEventReceiver
{
#region Properties
/// <summary>
/// The site templates
/// </summary>
enum EnmSiteTemplate
{
BLOG, //Blog Site
}
/// <summary>
/// English Language
/// </summary>
enum EnmLangugeCode
{
English = 1033
}
#endregion
#region Events
/// <summary>
/// A site was provisioned.
/// </summary>
public override void WebProvisioned(SPWebEventProperties properties)
{
base.WebProvisioned(properties);
try
{
SPSecurity.RunWithElevatedPrivileges(delegate
{
//Create a web object
SPWeb _web = properties.Web;
//Check and apply the settings
if (_web.WebTemplate == EnmSiteTemplate.BLOG.ToString() // If the site is a blog site
&& _web.Language != (int)EnmLangugeCode.English) // Language Selected is not english
{
// Get the Library with correct folder
SPFolderCollection _folderInList = _web.Folders["Lists"].SubFolders;
//Find a folder with "post.aspx" & "newpost.aspx"
SPFolder _folderBlogNonEnglish = (from _folderX in _folderInList.Cast<SPFolder>()
let _fName = _folderX.Name
let _fCount = (from _fileX in _folderX.Files.Cast<SPFile>()
where string.Compare( _fileX.Name , "post.aspx" , true ) == 0
select _fileX).Count()
where _fCount > 0
select _folderX).FirstOrDefault();
//So if any folder this properties exists
if (_folderBlogNonEnglish != null)
{
//The folder where file is going to come
SPFolder _folderBlogInEnglish = _folderBlogNonEnglish.ParentFolder.SubFolders.Add("Posts");
_folderBlogInEnglish.SubFolders.Add("Attachments");
_folderBlogInEnglish.SubFolders.Add("Post");
//Copy the files to new folder
foreach (SPFile _file in _folderBlogNonEnglish.Files)
{
_file.CopyTo(string.Format("{0}/{1}/{2}", _web.Url, _folderBlogInEnglish.Url, _file.Name), true);
////Add a file
//_folderBlogInEnglish.Files.Add(_file.Name, File.OpenRead(_file), true);
// Commit
_folderBlogInEnglish.Update();
}
}
}
});
}
catch (Exception Exc)
{
SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("VariationBlogSiteEvent", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, Exc.Message, Exc.StackTrace);
}
}
#endregion
}
}
Hope this helps. If you have any questions or a better solution, I am all open for it. Thanks for reading the blog.