Monday, March 30, 2009

default.aspx with custom type and layout under Variations


Gaaa!! This was difficult and I am not still sure this was the best way.

Objective was (I guess this is for everybody who uses Sharepoint Publishing portal with Variations enabled. For us, this is to support multiple languages) to have a custom content type and a page layout associated with it for default.aspx, when a subsite is created. And the subsite is propagated by Variations as it is.
That is, you create a subsite in the source label. The default.aspx is of your custom type and layout. And you see the same on all target labels.

First, to have default.aspx of a custom type and layout is achieved, by having a custom Site Definition defined and specifying it upon creation of subsites.

If the objective is just this, you may not need to use a custom Site Definition.
(Although it is a bit backdoor-way) I think we could use as well the Site Template technique. The GUI is provided. Thus, it can be done by a series of clicks.
This was not my option because of the Variations.

Suppose you create a subsite in the source label, based on a Site Template with default.aspx being of your custom type and layout.
The propagation of default.aspx fails because the type does not match.
This is because when Variations creates the subsite (propagation) in a target label, it does so based on the Site Template that you selected when you created the source label. It is either Publishing Site with Workflow or Publishing Site. For both, content type of default.aspx is set to Welcome Page.

How to have our custom Site Template selected there? The answer that I found was to come up with a custom Site Definition.
What I did at the beginning was rather simple. I create my definition having the BLANKINTERNET as basis, and just changed the default.aspx provisioning part so my type and layout are used. This what I have in my onet.xml.

<Configuration ID="2">
...
<Modules>
<Module Name="SubWebWelcome" />
</Modules>
</Configuration>
<Modules>
<Module Name="SubWebWelcome" Url="$Resources:cmscore,List_Pages_UrlName;" Path="">
<File Url="default.aspx" Type="GhostableInLibrary" Level="Draft" >
<Property Name="Title" Value="$Resources:cmscore,IPPT_HomeWelcomePage_Title;" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/mylayout.aspx, ~SiteCollection/_catalogs/masterpage/mylayout.aspx" />
<Property Name="ContentType" Value="mytype" />
</File>
</Module>

OK. Fine. Looked nice at first. But then I realized that layout is OK but not for the type. The type is Page, not “mytype”.

Actually, up to this far, seems there are many doing the similar. I found blog posts discussing it.
But I found none specifically talking of type. They seemed all happy having their custom layout with default.aspx. Do not tell what happened with the type.
Could be my mistake, oversight somewhere. But I could not figure it out…

After another sometime on the net, I found some people adding custom types to the Pages document library using Feature invoked when a site is created. I gave it a try.
# I later found that the same can be achived using a Feature XML element (
http://msdn.microsoft.com/en-us/library/aa543152.aspx), in which case you do not have to do any coding.

Now mytype is added, after the three default types. But still, default.aspx is of type Page, not of my type.

I thought that this may be because the default type of the Pages library is the Page, although it does not make sense because when we create a page thru the UI, it becomes of the type and layout we specify, not of the default type. Actually, when we do so thru the UI, we do not have to add the type first, to begin with.

I looked for a way to change this default (type selected in a document library). But found no such method provided with SPList. It appears that a type is the default just because it comes at the top.

So I decided to see what happens if I deleted the three build-in types, after having added mine.
Bingo!! Now I have the default.aspx created as of my type as well as layout. And since the same definition is used when the site is created in a target label by Variations, there too, the default.aspx is of my type and layout, so the contents are properly propagated.


Monday, March 2, 2009

Zip size limit, 32-bit and 64-bit


Still FTP migration.

Sometimes one folder is really big. Many files; each rather big. I had problems when unarchiving.
I do not copy it here but from the error message, it seems the upzip can not find the file end.

Found this page.
http://www.info-zip.org/FAQ.html#limits
Says the actual size limit for an archive file is 2G on 32-bit and 4G on 64-bit environment.
This explains.

Actually, in my case, the target is 64-bit Windows 2008. We migrate files from a Tru64 UNIX. 4G should be big enough.
However, the info-zip Unzip.exe that I mentioned that I have got in the last post is compiled against 32-bit DLLs, and it reads here (http://www.info-zip.org/board/board.pl?m-1235603338/) that there is no 64-bit Windows version available as of Feb 27/2009.
It says also that I should be able to compile it and can report for any problem. I might want to try that some other time when I am bored but not now.

So I used the –i and x options of zip command to include and exclude some type of file into one but not the other one, to keep one archive less than 2G.
The mission seemed completed but in course of doing this, I have lost the time stamps of some of the files…