Skip to main content


Showing posts from 2014

SVG Files and Sitecore

Sitecore by default does not support the SVG image types. You'd have to incorporate the following in your web.config to be able to make SC serve the SVG as an image instead of a file for download.

       <mediaType name="SVG image" extensions="svg">
          <mediaValidator type="Sitecore.Resources.Media.ImageValidator"/>
            <generator type="Sitecore.Resources.Media.ImageThumbnailGenerator, Sitecore.Kernel">

Web Forms For Marketers - Custom Unique ID Field Type

I recently had a request from the business to implement a unique 8-digit (auto-incrementing) Reference number for one of their Forms. Doing a quick scan in the available Field types, I found that there wasn't any type available that fits my requirement.  I had two options to consider:

Override the Save to DB action: by overriding the Execute method and replacing the AdaptedResultList with my own which queries the WFM DB and looks for the Max Reference value and returns the incremented value at that instance; this worked well but I quickly ran into an issue wherein other Save Actions (like Send Email) were still using the original AdaptedResultList and thus the experience was inconsistent. If I were to go this route, I would have to override every possible Save action which is not very good. So I concentrated with my next option:  Create my own Custom Field Type: I created my own type, did the necessary changes in the WFFM module settings like (add a new Field Type referencing my n…

Add Export to File Functionality in Sitecore's Search Options

One of our business users was requesting for a listing of items they've already added and have it available in a format that can be opened in a spreadsheet (Excel). My initial thought was to create a blank aspx page and write all the logic to get the data in the code-behind, run it and save the resulting file to a csv then I'm done.
But then it got me to think, it might be a better idea to have this functionality plugged in to Sitecore and made available for everyone to use.  Sitecore Bucket's Search Options fly-out seemed a good candidate for this feature (See image below). So doing some quick readings I got myself in to the "zone" and started implementing this quick and dirty PoC.

Just to explain what it actually does.

User will basically do a search, (Note that all search options require some filters or search keyword before any of the options can be used) clicks the Export to File, it pops up a dialog to confirm the action and executes, after which a browser-…

Sitecore and Universal Analytics

We recently moved from Google's Classic Analytics to Google's Universal Analytics, and I would like to share a few practices we used to make the transition easier.

We have a Google markup Item we created in the content editor (simple text field) which we use to dynamically inject the UA code to the layout using a Literal that will accept the final <head> UA markup.Try to move all UA scripts from inline to a separate js file. This is a huge maintenance win for us as we have a central location where any UA changes can be made. The JS file basically is a "document.ready" script where all the elements and events we'd like to capture are placed. Use jquery's excellent 'binding' capabilities to be able to 'attach' an event to any specific element you have in your Sitecore pages. We have another version of this same JS file that basically just contains pop-up alerts containing the actual UA call. This helps our SEO Analysts to check if the scrip…

Sitecore StringUtil Class - Part 1

While playing around with the Reflector today,  I chanced about the StringUtil class inside the Kernel.
If you are working with a lot of links in Sitecore, you would have encountered the function EnsurePrefix, that takes in a char and a string as arguments; this is one of the members of this class. Aside from this uber useful utility here are a list of what you can also pick up and use inside this sealed class.

Function/MethodParametersDescriptionArrayToStringArray, charMakes strings out of ArraysCapitalizestringUppercases the first letter of a string and lowercases the remaining letters. Clipstring, int, boolClips a string at a certain length. The bool argument is for the ellipsisCombineobject, object, stringCombines the ToString() representation of the two objects separated by a string dividerConcatobject[]Accepts a collection of objects and concats the ToString() representation of each valueContainsstring, string[]Looks for the first instance of the string in the string[] object. Re…

Rich Text Editor (RTE) Stripping Script tags

Ran across an issue today wherein one of our Content Editors was complaining that their page was not working, i.e. some page scripts where not firing.
Upon closer inspection, we found out that their content inside their RTE was missing.
We added them back but, it just kept getting stripped-off when we close the editor.
This did not happen to us before when we were using SC6.5, so this basically smells more like an upgrade issue.
I scanned all of the config changes (I kept a log) and found one curious setting:

<setting name="HtmlEditor.RemoveScripts" value="true" />

This setting was by default removing any embedded scripts inside the RTE.
Just turn it off in your CM and keep it on in your CD.

Implementing a Secure Media library in Sitecore

Our internal clients wanted us to secure some of their resources stored in the media library so that only authenticated and authorized extranet users are able to view or download them. Our current setup has the following components, I'll simply focus on the 3rd and 4th points:
Sharepoint Workflows on a Sharepoint 2007 Server. This serves as the working repository of the resource owners.Sitecore Sharepoint Integration Framework. This hooks up Sitecore with the designated document library in Sharepoint for all finalized files/documentsIntegration folder in the Media libraryLogin page to handle the authenticationCreate your login page. You have the option to create your sublayout for this (mostly to control the page contents etc.) or you can just quickly create one and put it in one of your folders in your solution. I normally use CodeFile directive in my pages as we found it easier to maintain this type of setup in the long run. There are plenty of samples of the login functionality …

SC 7.0 Certified!

Yey! I just finished 4-day Sitecore 7.0 developer training in Chicago and passed the certification.
My thoughts:
Over-all good training,Good trainer.I would have hoped they had some printouts as it was pretty tedious to go Alt+Tab'ing the whole time we had to do the exercises. In 6.5 we had all these materials with us.

Sitecore 7.0 Upgrade (from 6.5) Sharepoint Integration Framework 1.0 Upgrade

Part of the extra work in the SC upgrade process is making sure that your modules still work after the upgrade. Since we were using SPIF as one of our major modules, it was important that this was validated and updated as well.
From our current 111115 revision, we chose to upgrade to 1.1 rev 130613. Installation was pretty straightforward we followed the SDN instructions nothing difficult there. What struck us though was the note in one of the upgrade path; it says, upon first access, any existing integration folder will be recreated.
Whoa! This did not sound too refreshing to us as we already have thousands of references to these integration items.
We had to find out a way to sync the refs once the upgrade completes, one route we took was to leverage the SC Links DB.
We used the steps below:
1) After upgrade, rebuild the Links DB, since the web DB still contains the current live refs, we can use the media IDs here as refs once the SPIF in master has refreshed.
2) We then created a on…

Sitecore 7.0 Upgrade (from 6.5) Search Dropdown Issue

We hit a snag in one of our instances that we we were upgrading. The upgrade finished but once we we were validating the site, none of the Search Options Dropdown was displaying.
I ran a compare on the files from a working copy to that of our instance and could not find any major difference so I suspected this to be data-related.

I could not figure out what was different from the working to that  of my instance so I decided to package the Items related to Buckets and install that to my target non-working instance. And voila! it works.

I opened up a ticket with Support to get to the root of the issue and provided them with the Buckets package (before I overwrote it).

They found out that the /sitecore/system/Settings/Buckets/Settings/Search Box Dropdown was not having any version! They gave it one and the dropdown now works.

Sitecore 7.0 : WFFM 2.3.0 - End of String Expected Error

Got hit today by this issue when I was validating our latest WFFM installation for our Dev SC7.0 instances. Some existing pages with WFFM forms in them where throwing these exceptions. After a lot of searching and troubleshooting, I remembered that I ran into this issue before; with the Sitecore queries. SC queries in particular do not like "and", "or" and "-" in item names (paths). I suspect, Sitecore.Forms.Core.dll contains a new call using an SC query.

Looks like this breaking change was not documented in the SDN.

My current alternative is to move these affected forms elsewhere i.e. under items without the prohibited character and words.