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.

Thursday, June 4, 2015

50 Shades of Gandalf the Grey

Every now and then I decide to goof off while working. It's not the kind of goofing off where I play put-put or Call of Duty while on phone calls, but the kind where I might be doing a screen share with a colleague and, knowing that they aren't paying attention, I decide to start writing something curious. This time, I decided to start with something that could be suggestive or provocative at first glance, and end with a total nerd-out. Keep in mind, I wrote this in maybe 5 minutes, so it's not incredible, but I thought it was fun enough.

And since this is my blog, I decided to share that blurb with the world that stumbles upon it.

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.

Thursday, March 19, 2015

Working with Syntax Highlighter in Blogger Simplified

I’ve been attempting to clean up my blog and make it a little more user friendly for myself and visitors, and given that it’s a blog by a developer, there is bound to be a code sample or two posted on it. When I see a code sample on a site, I like to be able to scroll the code block to see the full thing, or highlight sections to copy if I like. Needless to say, it’s important to display code samples properly on a blog for coding.

When I was first throwing this blog together I searched for the best approach to displaying code samples. Some people were using Syntax Highlighter with some tweaks and troubles here and there; others said the simplest approach was to just create a GitHub Gist and copy the Gist embed URL into your post. The Gist approach seemed the simplest so I decided to go with that to start. Well, now that I tackled that with all the effort it took (none, seriously) I decided to try my hand at Syntax Highlighter.

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.