Issue
Read this blog -> Sharepoint 2010 - Strange blog URL issue with site using Variations(Multilingual site). - REALLY WEIRD ISSUE!Solution
- Create a Feature Stapler.
- Set the event scope as Scope="Site" as the feature.
- Stapler > Element.xml.
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureSiteTemplateAssociation Id="edf698b1-30db-4d19-b46b-5efbb5dae9a5" TemplateName="Blog" /> </Elements>
- Please use the below given code as a solution for the problem.
#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.
Interesting piece of information, I had come to know about your web-page from my friend, Jaipur, I have read atleast eight posts of yours by now, and let me tell you, your blog gives the best and the most interesting information. This is just the kind of information that I had been looking for, I'm already your rss reader now and I would regularly watch out for the new posts, once again hats off to you! Thanks a million once again, Regards, Best SharePoint 2013 Online Training Institutes in Hyderabad India
ReplyDeleteReally good piece of information, I had come to know about your site from my friend, Kolkata, I have read atleast nine posts of yours by now, and let me tell you, your site gives the best and the most interesting information. This is just the kind of information that I had been looking for, I'm already your rss reader now and I would regularly watch out for the new posts, once again hats off to you! Thanks a lot once again, Regards, Best SharePoint Training in Hyderabad India
ReplyDeleteAttractive piece of information, I had come to know about your blog from my friend, Ahmedabad, I have read atleast eleven posts of yours by now, and let me tell you, your website gives the best and the most interesting information. This is just the kind of information that I had been looking for, I'm already your rss reader now and I would regularly watch out for the new posts, once again hats off to you! Thanks a lot once again, Regards, Best SharePoint 2013 Training in Hyderabad India
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThanks for your informative article on software testing. Your post helped me to understand the future and career prospects in software testing. Keep on updating your blog with such awesome article.
ReplyDeleteSharePoint Course