labs.steveottenad.com

Collapsed Ribbon Buttons bug

So, we encountered an odd issue today while styling the Sharepoint 2013 ribbon on a publishing page. No matter the width of the page, the ribbon was always displaying the collapsed/dropdown version of the button bars. Resizing the page made no difference, and on inspection of the DOM/CSS, there weren’t any errant scripts or such that would be miscalculating the size of the parent container.

sharepoint 2013 ribbon bar collapsed responsive view

Always Collapsed…

After a while of searching, the culprit ended up being the HEIGHT of the bar itself, not the width. Our client had requested a slightly larger height on the ribbon in order to keep some borders looking nice (they butt up against the buttons too much for their liking in the original form), so we added

ms-cui-tabBody{ height:110px }

This was the style attribute that ended up breaking the bar and causing it to behave as if it were in its smallest responsive mode. Oddly enough, simply adding padding-top or padding-bottom to this class did not replicate the behavior, so I am hesistant to say it is due to changing the overall height of the ribbon. If anyone could shine light on why this would happen in the comments, that would be great.

jService.io

Screenshot 2014-02-12 19.14.01

I just wanted to show everyone jService.io, a set of services I just made to help surface the over 108,000 jeopardy clues scraped into a DB. The technology stack is as follows:

  • Ruby on rails
    • Nokogiri
    • Chronic
    • Bootstrap 4
  • Coffeescript
  • Postgresql
  • Heroku

Check it out on github as well at http://github.com/sottenad/jservice

 

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.

Sitecore: Cannot Rename Root Sitecore Folder

Its been a while since I’ve used the default Sitecore Installer (the .exe provided from sdn.sitecore.net), and I ran into a different problem while standing up a new instance today:

  1. Run the installer, name my instance “NewInstance”
  2. Realize that instance name is non-descriptive, so I do the following:
    1. Change the IIS App Pool and Web Site Names
    2. Change the Hosts File Entry and Web.Config entry in the <sites> node
    3. Go to change the folder name in my inetpub\wwwroot – CANNOT CHANGE

After a few minutes of hair pulling, I realize the issue is that Sitecore handles its DB creation a bit differently than we are used to here at Blue Rooster. We typically keep our LDF and MDF files for our DB’s in the default MSSQLSERVER folder, whereas Sitecore stores them along side the Site in the “Data” folder.  After realizing this, I just ran a quick

  net stop MSSQLSERVER

Quickly changed my folder name, then ran

  net start MSSQLSERVER

to turn the server back on. Not a solution you’d want to try on production, but a quick and easy fix for when you’re renaming a dev or local installation.

Error: Sitecore.Analytics.Data.ItemRecords

[NullReferenceException: Object reference not set to an instance of an object.]
   Sitecore.Analytics.Data.ItemRecords`1.b__7(Item item) +25
   Sitecore.Analytics.Data.d__a.MoveNext() +217
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +87
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +327
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
   Sitecore.Analytics.Data.TrackingField.ProcessProfileKeys(ContentProfile profile,
   ProfileItem profileItem) +120

Our team ran into this error while troubleshooting an analytics reporting error after upgrading Sitecore to DMS 6.6. Turned out the solution was to be sure to republish ALL of the system folder to all publish all the Templates in the System/Analytics folder.

Sitecore: Cannot Remove Templates

This is a follow up to my original review on the Sitecore Template Usage Reporter

After using the Template Usage Reporter to find out that many of my Sitecore Templates were being used on other Items, I quickly changed those Items Templates, and then went to remove the Template. No Dice. I followed the following steps:

  1. Found the Items using the “Old Template”
  2. Changed the Template on those items to “New Template”
  3. Saved + Published those items
  4. Tried to delete “Old Template” – No Luck
  5. Ran the Template Usage Reporter again, the same items were showing!
  6. Returned to those items listed, and turned on “View Standard Fields” by going to the “View” tab on the top bar, then checking the box next to “Standard Fields”.
  7. Sure Enough, the Old Template was still listed as an Insert Option.
  8. Remove the Old Template from the Insert Options and save
  9. Delete Old Template – Success!

Note: you also (interestingly enough) have to delete a Templates Standard Values before you can delete that Template itself. I seem to remember not always having to do this, so YMMV.

Review: Sitecore Template Usage Reporter

Sitecore-Template-Usage-Reporter

Dealing with removing templates during refactoring in Sitecore can be a bit of a bear. Sitecore will not let you remove a Template that is in use by any item, yet refuses to tell you which item(s) are using it. This can be a very frustrating search to find all the items that use or inherit from a particular template.

Enter the Sitecore Template Usage Reporter

Install:

  1. Download the package from http://marketplace.sitecore.net/en/Modules/Template_Usage_Reporter.aspx (you dont need the source, just the Version 1.0 zip.
  2. Open your Sitecore Desktop, and click the Sitecore button ->Developement Tools -> Installation Wizard
  3. Follow the Wizard to upload and install the package.
  4. Once the package has finished installing, restart the Sitecore Client.

To Use the Template Usage Reporter

  1. Open the Content Editor (Sitecore button -> Content Editor) or the Template Manager (Sitecore button -> Template Manager)
  2. Navigate to the Template you wish to delete
  3. When you select that template, you should now see a tab named “Template Usage” in the right pane.
  4. Select that tab and click “Run”.
  5. Voila, you now should see all the items that use or inherit from that template. If you wanted to play with the “Level” checkboxes, should be able to control what level of Template Inheritance you query. However, I’ve never tried this, 5+ works well for me every time.
  6. You can open any item by double-clicking that row in the results.

Notes:

  • I installed this plugin using Sitecore 6.6 Rev 4 and it installed properly, I would think you could ignore the install note saying Sitecore 6.2 ONLY. Or at least give it a shot on your machine.
  • Thanks again to Sitecore and Seth Luersen for this plugin

Quick Fix: Bad Sitecore Query (Using Item Web API)

Sitecore-Bad-Sitecore-Query
We ran into Sitecore misbehaving when passed a normal sitecore query, something that looked like this

$.getJSON("/-/item/v1/?query=fast:/sitecore/content//*[@@id='{2DFC08B5-9C0B-402B-9CA0-E9DCD00FD6BA}']//*");

At first, I was suspect of the fast: query, or even the ability to use the default Sitecore Item Attributes (found here). In the end, it turned out to just be that the Item Web Api needs to have its value URL Encoded prior to being sent to the API. It makes sense really, especially if you’re dealing with special characters. Here was my (simple) revised code:

var query = '/-/item/v1/?query=fast:/sitecore/content//*[@@id="{2DFC08B5-9C0B-402B-9CA0-E9DCD00FD6BA}"]//*';
var encodedQuery = encodeURIComponent(query);
var results = $.getJSON(encodedQuery);

Access Sitecore.Context.Database in a Web Service

Access-Sitecore-Context
In our attempts to move more of our code into Asynchronous web services for Big History, we struggled with keeping access to

Sitecore.Context.Database
in order to make calls to the Sitecore database. We tried a number of methods first to just not use the Context.Database at all. First, we just called the database using the GetDatabase method, then fired our DB call referencing that DB. Defining a constant somewhere and

var database = Sitecore.Configuration.Factory.GetDatabase("master");
Item unit = database.GetItem(unitId);

This worked for a while, until we tied some of our larger chunks of code into web services and were looking at some pretty serious refactoring to get everything setup using the method above. Looking for a solution that actually allowed us to use Sitecore.Context.Database, I figured out our hangup had something to do with the usual Sitecore rendering pipeline not firing and populating all of the Context.

Final Solution

If your approach to Web Services is anything like ours, you had your Service URLs in the

IgnoreUrlPrefixes
to allow traffic to get to them via javascript. Turns out this is what prevents all the necessary pipelines from running (seems extremely logical in retrospect). Remove your service urls from IgnoreUrlPrefixes, and add “.ashx” to the
Sitecore.Pipelines.PreprocessRequest.FilterUrlExtensions
pipeline in your Web.config. Your config should look something like this.

<processor type="Sitecore.Pipelines.PreprocessRequest.FilterUrlExtensions, Sitecore.Kernel">
   <param desc="Allowed extensions (comma separated)">aspx, ashx, asmx</param>
   <param desc="Blocked extensions (comma separated)">*</param>
   <param desc="Blocked extensions that stream files (comma separated)">*</param>
   <param desc="Blocked extensions that do not stream files (comma separated)"></param>
</processor>

Once all that is changed, you should have access to the entire Context object just like you would in any other Layout or Sublayout. One hangup to be aware of, is that if your service doesnt live inside a folder that is defined as a site in your Config, you’ll have to either create a new Site for it in your config, or just move the folder. For instance, if your site definition looked like

<site name="localhost" notFound="" hostName="localhost" virtualFolder="/" physicalFolder="/MYWEBSITE" rootPath="/sitecore/content" startItem="/Item" database="master" domain="extranet" allowDebug="true" cacheHtml="false" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" patch:before="site[@name='website']" />

and your service didnt live inside the “MYWEBSITE” folder, you’ll need to move your service, or add another site that points at the folder containing your service.

Introducing Exportagram

Exportagram

After reading instagrams new Terms of Service (http://instagram.com/about/legal/terms/), which they have no doubt since amended, it seemed millions of people were poised to drop the service entirely. The recommended service, Instaport (http://instaport.com) had buckled under the strain, so I whipped up a service of my own using:

  • PHP
  • Instagram API
  • Bootstrap 2.0
  • jQuery

http://exportagram.com

Overall I’m happy with the spartan appearance, and knowing that it only took 3-4 hours from idea to fully hosted site with a URL, twitter and facebook page is pretty awesome.