Blog posts by Null2014-04-02T10:15:26.0000000Z/blogs/Null/Optimizely WorldGetting “Site Only contains Core Files” when Language resources are altered in a bad way./blogs/Null/Dates/2014/4/Getting-Site-Only-contains-Core-Files-when-Language-resources-are-altered-in-a-bad-way/2014-04-02T10:15:26.0000000Z<p> <p>Starting with a perfectly good working site, some languages need to be added in the Views.xml to support them. These languages are Japanese, Korean, Vietnamese, Kazakh, Malay etc. When adding those languages us programmers immediately think of the corresponding Top Level domain names for those countries as the Language id : jp, kr, vn, kk, and my. In this list only the kk turns out to be correct. They should be ja, ko,vi, kk and ms. <br /> <br />When this file with the wrong id’s gets deployed to an EPiServer 7.1 site the site will display “This site only contains core files” grey screen. I think it is because the initialization ends in an exception. It would be nice if this exception bubbles up and be displayed. This blog post serves as a warning to check your language id’s and not rely on your knowledge of top level domain names.</p></p>Use connectorBlock to choose how a block is rendered./blogs/Null/Dates/2014/3/Use-connectorBlock-to-choose-how-a-block-is-rendered/2014-03-14T10:59:20.0000000Z <p>Blocks are nice to reuse content, EPiServer developers already know all the benefits of using blocks. A while back a customer asked me if it was possible to “remove the white space around a set of blocks in a content area so the whole set looks like one block, but other blocks, let’s say the first and second block should look as one block and then block 3, 4 and 5 should look as one block”. like so :<a href="/link/2756729ca63e404882d616b6fc67d551.jpg"><img title="blocks" style="border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; margin-left: 0px; display: inline; border-top-width: 0px; margin-right: 0px" border="0" alt="blocks" src="/link/591c989f23e6497f8674ea9be85d543d.jpg" width="240" align="left" height="185" /></a> Now I first thought let’s make a boolean property on the base type “IsConnected”, this worked fine but when the same block was used somewhere else the block was always connected. This was unacceptable according to the customer. </p> <p>Then I thought of an empty blocktype called Connectorblock, it does not render anything but when in the content area it “stitches” the blocks together, allowing for different stitching on different pages.</p> <p>I wrote a helper to retrieve the correct css Class</p> <p style="height: 60px; width: 100%">Code:</p> <p>public static class GroupingClassHelper <br />   { <br />       public static string GetGroupingCssClass(this HtmlHelper helper, IList<ContentAreaItem> items, int index) <br />       { <br />           const string firstCss = "group first"; <br />           const string attachedCss = "group attached"; <br />           const string lastCss = "group last"; </p> <p>           bool NextItemIsConnector = false; <br />           bool PrevItemIsConnector = false; </p> <p>           if (index < items.Count - 1)  // don't go out of bounds <br />           { <br />               NextItemIsConnector = ((items[index + 1].GetContent() as ConnectorBlock) != null); <br />           } </p> <p>           // if this is the first block then this one gets class first or (null if the next block is not a connector) <br />           if (index == 0) return NextItemIsConnector ? firstCss : null; <br />           var prevContent = items[index - 1].GetContent() as ConnectorBlock; <br />           PrevItemIsConnector = (prevContent != null); </p> <p>           // if previous block is a connector is then this block gets attached class or last class if the next one is not a connector <br />           // else (previous block is not a connector and this block is not the first block (index > 0)) then this block gets class first (null when next one is not a connector) <br />           return PrevItemIsConnector ? (NextItemIsConnector ? attachedCss : lastCss) : (NextItemIsConnector ? firstCss : null); <br />       } <br />   }</p> <p>Now all you need to do is add connector blocks between the blocks that need to be stitched together and alter your CSS to render the margins accordingly.</p> <p>I hope somebody has any use for this idea.</p>