Monday, January 5, 2009

Sharepoint Variations

Over the October - December, 2008 time frame, I finally a project that involved variations. I had poked around in the Publishing variations class a little and saw some cool stuff there, but was never able to find any really good posts or webparts that peeked my interest enough to pull me away from my current work load.

Then I got lucky enough to be involved in a project where Variations were a prime need. First, a little info about variations:
  • Variations are part of a Publishing Site. In the site collection settings of a publishing site, you can see the controls at the bottom of the right most column. These settings include:
    1. Variations
    2. Variation Labels
    3. Variation Logs
    4. Translatable Columns
  • Interestingly enough, using variations and creating the heirarchy in Sharepoint creates links to the sites on the quick launch, but does not expose the Variations control, which you have to manually uncomment out in the VariationsLabelMenu.ascx page in ControlTemplates. This control exposes a dropdownlist that contains the list variations and a post back to load the selected variation type. (Note: Exploring the code behind this control in the Mircosoft.Sharepoint.Publishing.VariationsLabelEcbMenu class can teach you a lot about how Sharepoint handles Variation Labels and navigation.)

More Later...

Been Busy....

I hope that other MS Sharepoint architects and developers are finding this a golden era of business. I have been so remarkably busy, I never am able to find any time to sit down and jot in my Blog.

Its been over a year and a half since my last post, and in that time I have worked on over 10 projects. I hope to finally add some tips and tricks I have picked up along the way to this blog.

Stay Tuned...

JMC

Wednesday, July 18, 2007

Trying to use a closed/disposed webpart.

Coming from a C++ background, I am a stickler for making sure my objects are disposed. I also know that cetain SP objects are extremely heavy, and should always be tossed when you are done with them. These objects include SPWeb and SPSite.

An error I know some developers run into is "Trying to use an SPWeb object that has been closed or disposed and is no longer valid." Let me try to shed some light on this, and also point out the correct way to create these objects.

There are 2 common ways to get our hands on an SPWeb object. One way is to use the SPSite.OpenWeb() method and the other is to use the SPContext.Current.Web method. Both of these methods will return to you the current Web, but the difference is that OpenWeb will return a Web object in a different memory space and CurrentWeb will return the Web object using the current memory space and thread.

As .net 2.0 developers, we are told to wrap our disposable objects in Using clauses, or (correctly) to use try/finally. The problem is that when you dispose of the SPWeb object after you gained a pointer to it from the SPContext, you are disposing of the object being used to render the page. Seldomly, Sharepoint recovers from the error, and goes on it's merry way. But more likely, the page will not render, and you will get the error.

As a best practice, if I am only going to fetch and display data, I use the SPContext object and do not dispose of the object, and when I plan on modifying or changing data, I use OpenWeb and dispose.

We all know that SharePoint tries to cover errors, and if a webpart function catches the error, but does not display it, then you can run into a situation where a container page is failing for an unknown reason. Your best bet is to try to add/remove the webparts on the page until the offensive webpart is discovered.

My friend Eric Stallworth points out that Microsoft covers this in this article
http://msdn2.microsoft.com/en-us/library/ms778813.aspx

Saturday, June 16, 2007

And Now Another Word Form Our Administrator

I see a whole lots of posts concerning the search drop down box missing some of the defined scopes from SharedServices. I recently ran into the problem on our farm and I thought I would pass along the fix.

The best place to start is to ensure that you actually have a SearchCenter site installed on the site. Without this, there will be no place for the scoped searches to land, and the scopes will not show up.

Once you have ensured that SearchCenter is installed, then go to SharedServices and make sure that the scopes are there. With MOSS, you will usually get two defined scopes out of the box, All Sites and People. Make sure that the scopes are there and that there is data in them.

If 1 and 2 are ok then next go to the base site for your collection. Log in as the SysAdmin and click on "Site Settings - Modify All Site Settings".

From All Settings, find the Search Scopes link in the Site Collection Administration column and click on it.

Sometimes SharePoint loses the scoping information, if it has lost it for your site collection, you will see your two scopes here in the category of Unused Scopes. In order to reset your scopes correctly, click on the "New Display Group" button on the menubar.

In order for the Scopes to show up in the Search Drop Down, place "Search Dropdown" in the Title box here. Place a description in the next field. Now check both of the scope "Display" checkboxes and select a position for each (usually it is All Sites (1) and People(2). Make the default scope "All Sites" and click on "OK"

When you return to the view you will see your defined scopes in the new Category: "Display Group: Search Dropdown(2)". And when you go to your site you will see that the scopes are now part of the dropdown box.

To set up Advanced Search, create another Display Group. In this group place "Advanced Search" in the title and check on "All Sites" and make "All Sites" the default, BOOM! Advanced search shows up.

Hopes this helps some of you frustrated Sharepoint people

JMC

Tuesday, June 12, 2007

And Now A Word From Our Administrator...

Alternate Access Mappings

What is it all about?

Many installations of SharePoint will not work in Browsers if the site is not trusted. Trust works at the domain level. When you create a SharePoint site, often times you have "http:/servername/pages/default.aspx" as your url. But you want to show "http:/mymoss.domain.com/pages/default.aspx" as your url.



In order to do this you have to modify the farm's AAM settings. These settings are located on the Operations tab in Central Admin.

When you open AAM you will see a list of all the sites in the farm and the default http for each site. Now lets say you want to use "intranet.domain.com" as the url for all users connecting to the site from the intranet.



Click on the site you want to add a mapping for, then click on "Edit Public Zone URLs". In the next screen you will see 5 defined zones and any defined mappings for these zones. Usually only the default zone will have a value.

In the intranet zone text box add "http://intranet.domain.com" and click on save, then reset iis. Now any user that connects to the server from the intranet will have the new url in their browser address.



As an added benefit, you can set one of four different security levels on each AAM Zone. So lets say you do not want people from the internet to be able to create or edit items on the Farm, you set the extranet url and then in admin set all users that connect to ReadOnly.



JMC