Pages

Friday, July 31, 2015

Properly adding Javascript in Blogger templates

Back in March, I wrote a post about a simplified method to use Syntax Highlighter in Blogger posts. The method utilizes a script I wrote so that I don't have to directly modify the html in a post (Working with Syntax Highlighter in Blogger Simplified). One of the issues I have run into with various scripts that have been posted, mine included, is the handling of special characters in the script. In certain conditions you need to look for an angle bracket or an ampersand using your script, and those special characters will break the Blogger parser when you attempt to add them directly in your script. In those examples, again, mine included, the special characters in the script have been replaced with their entity codes (see references below). For example, you can't simply add "<br>'.replace('<br/><br/>');" in a Blogger script.

After I posted that, I had a realization that you can simplify that condition, and future situations surrounding the use of Javascript in Blogger. Well, I finally got around to doing a quick test, and it seems to work without issue.

Tuesday, May 12, 2015

Sitecore List Fields - Item Not Found in Selection

I recently wrote an extension library for Sitecore to simplify setting values for fields.
Because of the way the specific field classes are created in Sitecore, setting values specific to the type of field can be tricky. For text-based fields, like Single-Line Text, Multi-Line Text, Rich Text, and a few others, you can actually set the value directly on a generic Field object with relative ease. For more complex types like lists, links, and images, though you can set the value directly on a generic Field object, setting the more specific options for the value needs more care.

So, I wrote an extension library to look at the Field type and set the value using the best method for that type. It worked great as far as I could tell, until I looked a little deeper during my "QA phase". And wouldn't you know it, it turns out there is a funky behavior with the list fields.

Tuesday, March 24, 2015

List Enum Types and Values in C# - Ektron Sample

Sometimes when you are working with an API you run across a scenario where the documentation doesn't outline exactly what you need, but you know it's there in the code. I have come across this scenario in several cases while working with Enumerations, specifically, where I knew I needed one specific value, maybe two, but I was uncertain exactly which ones they were.

Thankfully, with Visual Studio you can type a part of the Namespace, Class, or Enumeration, and then scroll through the list to see your choices for Enum types or values in Intellisense. Sometimes, though, that's a bit slow for finding exactly what's needed; especially when dealing with a list of over 150 options. This isn't always the case, but in those instances where I have a large list housed in a Namespace, Class, or two, I would prefer an easier method to visualize them, and maybe look through them.

Wednesday, March 18, 2015

Organizing Views in Sitecore

I have recently been working on a Sitecore project that is not terribly complicated, but has the potential to support multiple sites. The sites are similar in structure, and they will share some components, but there are many pieces of them that will be unique enough to warrant their own Views.

And with that magic word you can probably guess that this Sitecore instance is built with MVC. For a little more information about it, this instance of Sitecore is running version 7.5 and MVC 5.1 with Razor syntax.

The Problem

The problem is I want to keep an organized structure for my site not only with my Sitecore architecture, but also for my Controllers and Views. I am dealing with a Sitecore instance that will host multiple sites in the near future, so I have structured Sitecore to have different site-specific folders in my Content, Layouts, Media Library, and Templates sections. There are also Global folders in these sections where I will store items that are universal, but the specifics around my architecture can be saved for another post.