labs.steveottenad.com

Sitecore: Chilkat error

I run into this error about 50% of the time when I manually install Sitecore:

Could not load file or assembly ‘ChilkatDotNet2’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

Just putting this out there so others can correct it as well. What you need to do it Enable 32-Bit Applications on your App Pool in IIS

  1. Open the Start Menu, type “internet information”, click on the “Internet Information Services (IIS) Manager”. You might also have an IIS 6.0 Manager, do not use that one.
  2. Once open, in the left pane, expand the node with your computer name.
  3. Again in the left pane, click “Application Pools”
  4. Find your application pool in the middle column. If you dont know the name of your app pool, it is most likely whatever you named your site with “AppPool” on the end. By default Sitecore would name the app pool for “MyWebsite” “MyWebsiteAppPool”.
  5. Right Click the appropriate app pool and click “Advanced Settings”
  6. The second option down “Enable 32-Bit Applications”, flip that to True and click OK.
  7. Reload your site, that error should be gone. If its not, I would suggest looking at the ChilkatDotNet2.dll’s in your Bin as compared to a fresh copy of sitecore and ensure that everything is up to date.

Year In Review

Hey all,
Thanks for all the support, I thought I’d post some of the stats from the last year here on the blog.

Views

In the 12 months preceding this post (Aug-Aug): 51,624 unique pageviews
Top Pages:

I only actively promoted the search box tutorials, so you can draw a few conclusions from these stats. One, people routinely need to look up XSLT syntax. Two, Sharepoint basics are much more popular than the more advanced topics.

Comments

Top Pages:

While there isn’t a direct correlation between comments and views, this more or less follows the same pattern

Type Mismatch on wpadder.js

I encountered an odd error today working on a SharePoint 2010 Publishing site. After adding all my usual scripts, I was no longer able to use any Web Part adding functionality. Clicking “add a web part” in the web part zones did nothing. Trying to insert a webpart via the ribbon brought up the web part adder, but the majority of it was blank and just kinda busted.

I did however get this error

SCRIPT5: Type mismatch.
wpadder.js?rev=hnGJJEMcU5XH%2BCq7PlSxJw%3D%3D, line 2 character 13993

in the IE debugger under the Script tab error console.

Solution

Sharepoint (and possibly IE in general) has issues with any plugins/scripts that try to extend the Array Prototype. It appears that it breaks quite a few functions and generally is a good idea not to extend it if you dont have to.

So, to wrap it up. If you run into this problem, search through all your javascript for the string “Array.prototype”, or even “Array.” and you should come up with a hit (hopefully), comment that out or find a workaround for that piece of code and you’re good to go

Addition

We (mainly Adam Toth) found that less.js also causes an issue, due to the fact that it redefines all the prototype functions for Arrays. The same root problem, but it was a bit tricker to find. Make sure to do a full-text search on your entire project for the best results. I like Astrogrep to do this. It’s fast, thorough, and free.

More Offenders

Thanks to Bryan Gulley

Using SPServices to get list items from all folders

Using SPServices (link) is a great way to query lists using javascript, but there are issues when trying to get list items contained in folders. Typically, when using the “GetListItems” function, you will get back the folder as an item in your return object. This may be useful when trying to show the topography of the list, but not if your end users are using folders to organize content in the list. In the instance that you want to pull back ALL list items, regardless of whether they live in folders or not, you can add a quick line to your initial SPServices call to recurse through all folders and return all items.

Add CAMLQueryOptions: ‘<QueryOptions><ViewAttributes Scope=”Recursive”/></QueryOptions>’, to your initial SPServices call, and you’ll get back all the items, rather than just the top-level items and folders.

Example

$().SPServices({
	operation: "GetListItems",
	async: false,
	listName: "YOURLIBRARY",
	CAMLQueryOptions: '<QueryOptions><ViewAttributes Scope="Recursive"/></QueryOptions>',
	completefunc: function (xData, Status) {
		$(xData.responseXML).find("[nodeName='z:row']").each(function(i) {
                        var photo  = $(this).attr('ows_RequiredField');
                });
        }
});

Getting “ows_MetaInfo” with SPServices

If you use the SPServices library (link) to grab info from lists, you’ve more than likely ran into an instance where the information you need is contained in a gnarly string inside the “ows_MetaInfo” attribute. There is a very easy solution to change this large string into its appropriate attributes, making the information contained in it super easy to access. Just include CAMLViewFields: “<ViewFields Properties=’True’ />” in your initial SPServices call, and you’ll now have access to all that information as attributes instead of a string

Example

$().SPServices({
        operation: "GetListItems",
	async: false,
	listName: "YOURLIBRARY",
	CAMLViewFields: "<ViewFields Properties='True' />",
	completefunc: function (xData, Status) {
	 		$(xData.responseXML).find("[nodeName='z:row']").each(function(i) {
					var description = $(this).attr('ows_Description');
			});			
	}	
});

Sharepoint 2010 XSLT Date Formatting

The main goal of this article is to outline the snags I hit while trying to configure a SharePoint 2010 Content Query Web Part (CQWP) to display a feed of my recent calendar events. I was presented a very specific layout to use for displaying the latest results from a users calendar, and I knew I would have to jump in and write some custom XSLT for the CQWP to comsume.

Creating a New Style

Read the rest of this entry »

Add Custom CSS to a Sharepoint 2010 Site

Note: this does not work in WSS, only MOSS. You need the Microsoft.SharePoint.Publishing namespace for this tutorial to be of any use.

One of the biggest parts of creating a professionally customized Sharepoint 2010 site is being able to provide your own custom CSS. This allows you to alter the appearance of just about every element on the page, and provide your own branding in place of SP2010’s default styles. However, getting that custom CSS file hooked into your site can be a bit tricky.

Create Your CSS

Read the rest of this entry »

Find a SharePoint Site Collection URL in Javascript

As a front-end dev at a Sharepoint shop, I often need to reference various components (images, paths, etc) that have paths relative to the site collection url. Using only javascript to parse the URL and then figure out where your site collection is can be tricky at best. What I typically do, is use a tiny bit of .NET in the master page to define some global variables I know I’ll need down the road.

The Code

Create your global javascript variable with the site collection url by dropping this snippet into your master page

<script type="text/javascript">
	var siteCollectionUrl = '<asp:Literal runat="server" Text="<%$SPUrl:~SiteCollection/%>"></asp:Literal>';
</script>

Then you have a nice global variable that you can reference inside other js files like so:

<script type="text/javascript">
  alert(siteCollectionUrl);
  var newlink = siteCollectionUrl+"/path/to/file";
</script>

Notes:

Anything you can put inside a tag can be printed out into a JS variable this way. So don’t think that this is the only cool little snippet you can include using this method. Important: make sure you give your variables very unique names, as you dont want them to conflict with any others in the global scope.

Sharepoint Show All Rows in XSLT

Here is a quick snippet reposted from an old Heather Solomon article, referencing how to show all rows being pulled back by a web part using XSLT.

<xsl:for-each select="@*">
    P:<xsl:value-of select="name()" />
</xsl:for-each>

EDIT:

This method from Glyn Clough seems to work much better. It shows the property and the value, rather than just the property.

<xsl:for-each select="@*">
	<xsl:value-of select="name()"/>
 	<xsl:text> = </xsl:text>
 	<xsl:value-of select="."/><br/>
</xsl:for-each>

Adding Javascript to SharePoint 2010 Master Page

Including Javascript In SharePoint 2010

Adding scripts in a Sharepoint 2010 Master Page can be accomplished in a couple of different ways. I’d like to focus on what I consider to be both the easiest (once learned) and the most beneficial method, the tag. Keep in mind I am writing this article from the place of a (primarily) front-end developer. This is not geared at back end developers looking to use all of the functionality of the ScriptManager Tag.

Read the rest of this entry »