May 30, 2011

Resolving Sitefinity 4 Search Not Including Content Pages

I recently encountered an issue where, after creating a Sitefinity SearchIndex for NewsItems, Static HTML and all Content, only the NewsItems were being returned - no Content Pages or Static HTML pages appeared in the results. The response I got was to upgrade to Sitefinity 4.1, SP 1, which wasn't the complete answer, but at least the newer admin UI helped to troubleshoot the problem:

(SearchIndex creation screen)


After going through the upgrade process, helpful error messages began to appear when I re-indexed my SearchIndex, indicating errors were being thrown when certain pages were being crawled.

So the problem really was that one particular call, in this case:
SiteMapBase.GetCurrentNode();
was throwing a null reference exception, only during the Sitefinity crawling process, and quietly killing the addition of the Content Pages to the SearchIndex. After resolving the issue, the full site indexed correctly, and searching returned results as expected. There's no feedback when the SearchIndex is successfully reindexed, however, but you'll see the page subtly refresh. (Maybe a good feature for 4.2)

(SearchIndex admin screen)


After going through this process, I found that you could also troubleshoot indexing issues by launching your app in debug mode, going to the admin tool and re-indexing your problem SearchIndex... The Visual Studio debugger will then point out any problem code.

Share |

May 28, 2011

Styling / Formatting Sitefinity 4 controls

One of the big differences between Sitefinity 3.x and 4 is in the way the style and layout of the controls is handled. In the older versions, you had direct access to the .ascx code in either the ControlTemplates folder or the UserControls folder. In 4.x, all Sitefinity widgets have been compiled into .dlls, with each widget exposing a LayoutTemplatePath property, which allows you to specify a path to your own .ascx file if you need to change the layout beyond what is possible via the other widget properties. It's a cleaner way to do it - in the past, upgrades could overwrite revised template code - now your revised layouts are preserved when upgrading.

You can get to the default LayoutTemplates at Design > WidgetTemplates in the Sitefinity admin area. But here's one problem - many controls, like in my case the Login control, don't have any sample layout code exposed. The first thing I tried was to use the LoginControl ascx from Sitefinity 3.7. The first error message you'll get is:

C001: LayoutTemplate does not contain an IEditableTextControl with ID UserName for the username.


You can rename your controls to get through these errors, but you'll eventually hit a brick wall, as you really need the layout code. Fortunately, Grigori at Sitefinity was good enough to send me the actual LayoutTemplate code, which is not exposed anywhere within Sitefinity. Here is the actual Sitefinity 4 LoginControl LayoutTemplate Code. Grigori tells me this will be included in the next release.

Adding this code to your project, and pointing your LoginControl's LayoutTemplatePath to this ascx will allow you to format your login control any way you want:

Default LayoutTemplate appearance:


Login control using custom theme, css:

Share |

October 26, 2010

SSIS Error Code DTS_E_PRIMEOUTPUTFAILED

Recently, while working on a db integration using SSIS, I had encountered a generic error while working with an XML Datasource: Error Code DTS_E_PRIMEOUTPUTFAILED. There are several scenarios that can produce this error, and there also was another message specifying that the offending element was at character 14988 in the XML. The data at that point in the file looked fairly straightforward, which then led me down the path to thinking the file size might be the problem:

<word>with</word>
<word>a</word>
<word>vegetable</word> <- supposedly offending line
<word>white</word>
<word>rice</word>

After whittling down the data for a test, the problem still existed, so the problem wasn't file size either. It ended up just up being bad data... there were several ampersand (&) characters throughout the file.
The error message referencing character 14988 was just a confusing diversion. After scrubbing the data, SSIS was then able to successfully parse the file and use it as a datasource.

Here's a quick reference to characters needing to be escaped within XML, and their associated escape sequences:

Ampersand(&) - &amp;

Greater Than symbol (>) - &gt;

Less Than symbol (>) - &lt;

Double Quote (") - &quot;

Single Quote (') - &apos;

Share |

December 16, 2009

Facebook ActionScript API - Overall Architecture

The last few posts talked about setting up your Facebook app and Flex e nvironment, now let's look at how all the pieces fit together. There are several ways to call the Facebook API via Flex, but we're going to focus on creating an IFrame application. There are other ways to interact with Facebook, like as an FBML application, or even as a desktop AIR application Documentation of each type of interaction is available here. Here is the official diagram from Adobe on the architecture of a Flex IFrame app




I personally didn't Grok how it all fit together when I saw this diagram, so after I finished my first app, I whiteboarded this diagram.




1 - Your app. The url is http://apps.facebook.com/[your application name] . When this page appears in a web browser, the page contains an IFrame that references a URL on your web server.
2 - Your Facebook application settings point to your website. Facebook posts all required variables over the querystring into your containing HTML page, as well as reposting any other querystring vars, including any variable you may want to pass in.
3 - The index.htm file supplied from Adobe creates an array of all querystring variables passed into the page, and using the standard swfobject.js file, injects all variables into your .swf. I have usually had to tweak the code of this page to include/refine my personal application variables.
4 - Now your .swf is displayed within the IFrame on your Facebook application page, having evaluated all Facebook variables, as well as your own custom application variables.

Next post, we'll talk about some even easier ways to integrate a Flex/Flash app with Facebook, and talk about some best practices.

Share |

October 07, 2009

Facebook ActionScript API - Creating a Canvas/Project

In my last post, I talked about some prerequisites and things you might want to think about before integrating a Flash app using the ActionScript API. Now let's take a look at how to configure a Facebook canvas and get your local project set up.

The first thing you need to do to get started is to add the Facebook developer application by going to www.facebook.com/developers. This is just a Facebook application that allows you to register your application.


Once you've allowed access to the Facebook developer application, it's time to create your application and canvas. Give it a name and agree to the terms.


Once you've created your application, go in to Edit Application and you'll see that Facebook created an API Key and Secret for you. We'll talk about those later, but remember that you never want to give out your Application Key and Secret for security reasons. When the app is deployed we will be using a session-specific key created for us by Facebook when making our API calls, but during testing, we can use these codes to perform the calls locally.



Now we need to set up our Facebook Canvas. First in the box for the Canvas Page URL, give it the name you want your application to have on Facebook (apps.facebook.com/[yourappname]) in all lowercase. Then set the Callback URL... this is the path to YOUR server where the swf will be located. (It should be contained within an HTML wrapper page that we'll get from Adobe). We will be creating an IFrame application - in other words the page on our site will be "sucked into" an IFrame on our Facebook canvas page.


When we release, our application type will be Web, but for coding/testing/debugging purposes, make the application type Desktop, so we can just pop up a window to allow access, and test our Facebook API calls locally.


Now we need to download a few files from Adobe to set up our application in Flex (0r Flash).
First, get the Facebook-ActionScript-API from Google Code (http://code.google.com/p/facebook-actionscript-api/downloads/list).



Then get the iframe wrapper from http://download.macromedia.com/pub/developer/flexfb_iframe_wrapper.zip . After you unzip the file, you'll see it contains an html wrapper page for your swf, plus swfobject.js. We'll look later at what this html wrapper page does.


Now we need to go ahead and create our project in Flex Builder, make sure it's a web application.


In the libs folder, go ahead and add the Facebook library you downloaded from Google Code.


...Now you're all set to start development on your Facebook Flash application. That's a lot for one blog post, so next time we'll take a look at really Grok-ing how and where everything goes, as well as looking at other Flash-Facebook architectures as well. (A much more in-depth walk through is available on the Adobe devnet site).

Share |