Showing posts with label site definition. Show all posts
Showing posts with label site definition. Show all posts

September 27, 2007

MOSS: Populating folders containing items to a list in Site Definition

Problem:
In Site Definition, one can define the default folders or items that are created to a list on a site when the site is created using Lists-List-Data-Rows-Row-Field elements.

How to create folders that contain items, i.e., a hierarchy of folders containing items?

Thoughts:
Cannot be done using current web's feature receivers since the list items do not yet exist when the features are activated.

Workaround:
Create a feature that moves the items into correct folders in the list. Activate this feature programmatically after the site is created.

Solution:
Unknown

May 16, 2007

MOSS: This page is not using a valid page layout.

Problem:
When creating a custom Site Definition containing Publishing features, the site creation succeeds, but when entering the site you receive error: "This page is not using a valid page layout. To correct the problem, edit page settings and select a valid page layout.""

Solution:
See that you have Type set in the File element under Modules -> Module in the ONET.XML of the Site Definition.
<File Url="default.aspx" NavBarHome="True" Type="GhostableInLibrary" Level="Draft">

April 18, 2007

MOSS: Discussion Board links point to default.aspx when creating List Views in site definition

Problem:
When defining Discussion Boards in Site Definition (in ONET.XML), the subjects of discussion threads point to default.aspx. This means that when clicking on a discussion subject the user is redirected back to the same page. Subject links should point to flat.aspx.

Thoughts:
Some blogs (1, 2) mention a KB article related to this problem and also a MS hotfix that might fix this problem, but it doesn't.

Solution:
Add ContentTypeID="0x012001" into the View element of the Discussion web part in your site definition like this:

<View list="Discussion" baseviewid="0" ContentTypeID="0x012001" webpartzoneid="LeftBottom" webpartorder="1"/>

ContentTypeID is now allowed there according to the schema, but it will still fix the issue.

March 19, 2007

MOSS: Creating subsites in site definition

Well, not really, but by using a MOSS 2007 Features you can automatically create sites below the site user just created. Other way to create sites is to use Provisioning.

FeatureEventHandler:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    using(SPWeb web = properties.Feature.Parent as SPWeb)
    {
        // Check that subsites do not already exist
        if(web.Webs.Count == 0)
        {
            // Create subsites
            try
            {
                web.Webs.Add("", "SubSite1 Title", "", 1033, "", false, false);
                web.Webs.Add("", "SubSite2 Title", "", 1033, "", false, false);
                web.Webs.Add("", "SubSite3 Title", "", 1033, "", false, false);
            }
            catch(Exception e)
            {
                throw new SPException("Error when trying to create subsites. Error: " +
e.Message);
            }
        }
    }
}

Create new subsite Feature:

<feature id="7F4AA5EF-6A62-4a08-8565-DE39C02839E7"

title="Subsites"

description="Creates subsites for specific sites."

version="1.0.0.0"

hidden="TRUE"

scope="Web"

xmlns="http://schemas.microsoft.com/sharepoint/" receiverassembly="FeatureEventHandler,Version=1.0.0.0,Culture=neutral,PublicKeyToken=60a5c2355dc3549c"

receiverclass="Features.FeatureEventHandler">

</feature>