How to share MCMS content from a connected template in MCMS 2002 (840148)
The information in this article applies to:
- Microsoft Content Management Server 2002
SUMMARYThis article describes a way to share content from the Microsoft Content Management Server 2002 (MCMS) placeholders in an existing posting. The article applies to a scenario when you must share some content from an existing posting of MCMS and reuse the content in a different template. By using the methods that this article discusses, you can create a connected page by using the MCMS Web Browser Client (WBC). You can also create a connected page by using the MCMS Publishing API (PAPI). INTRODUCTIONWhen you want to share part of the MCMS content from an existing posting and use it in other postings, you can create a connected page by using a connected template in the MCMS WBC or in the MCMS PAPI. This article describes how to do this without creating duplicate content in a MCMS posting. You must create a connected template and then create a connected page. To create a new posting that connects to an existing MCMS page, you must have editing rights to the existing posting. Additionally, you must have rights to create a new posting to the specified channel. back to the topCreate a connected template- Start Microsoft Visual Studio .NET, and then open an existing MCMS ASP.NET Web project solution.
- In Solution Explorer, create a new MCMS template file.
- On the View menu, click Other Windows, and then click MCMS Template Explorer. The MCMS Template Explorer window opens.
- Select a template gallery item (TGI) that contains content that you want to share. Right-click the selected TGI, and then click Create Connected. A connected template gallery item (TGI) is created.
- Right-click the new TGI, and then click Properties. Click Open Template File.
- In the Properties dialog box for the TGI, click the button next to the PlaceholdDefinitions property. The Placeholder Definition Collection Editor dialog box appears. Notice that all Placeholder definition collection items in the new TGI are defined from the source template in step 4.
- Add some PlaceholderDefinitions items in the new TGI, and then click OK.
- In the Properties dialog box for the TGI, click the button next to the TemplateFile property. The Select File dialog box appears.
- Locate and then click the new MCMS ASPX template file that you created in step 2. Click Select.
- Add MCMS Placeholder controls to the new template Web form that you created in step 3. These controls are located under Content Management Server in the Toolbox.
- Select one or more MCMS Placeholder controls that you want to use to get the content from the source template that you opened in step 5.
Note In the Placeholder control Properties dialog boxes, make sure that you use the same PlaceholderDefinitions item for the Placeholder ToBind property that is defined in the Placeholder control in the source template. - Bind the Placeholder controls that do not have to share the content from the source template in the step 5 to the PlaceholderDefinitions item that is defined in step 7.
- Check in the source TGI and the connected TGI, and then compile the MCMS ASP.NET Web project.
back to the topCreate a connected page by using the MCMS WBCAfter you complete the steps in the "Create a connected template" section, you can use the MCMS WBC to create a connected page. To do this, follow these steps: - In MCMS WBC Internet Explorer, log on to an MCMS Web site that permits authoring. Verify that you have the correct user rights to create a new MCMS posting.
- Locate the channel that you will use as the basis for the connected page, and then click Switch to Edit Site.
- In the MCMS WBC console, click Create Connected Page. The Template Galleries window opens.
- In the Template Galleries window, locate the channel where you want to publish the connected page. Select the connected template. Notice that the content that you want to share appears in the Placeholder controls that use the same PlaceholderDefinitions items in the source Placeholder controls.
- Because the page name is defined as the name that the source posting uses, you can provide only a display name for a connected page. If you want to provide a display name, type it in the Display Name box. Click OK to save the new posting.
- In the MCMS WBC, click Submit.
- In the MCMS WBC console, click Approve.
back to the topCreate a connected page by using the MCMS PAPIYou can also use the MCMS PAPI to create a connected page. The following sample code does this for a console application that is written in Microsoft Visual C# .NET. Note This sample code is intended for demonstration purposes only.
CmsApplicationContext CmsCnPosting = new CmsApplicationContext();
CmsCnPosting.AuthenticateAsCurrentUser(PublishingMode.Update);
try
{
Posting sourcePosting = (Posting) CmsCnPosting.Searches.GetByPath(strSourcePostingPath);
Channel targetChannel = (Channel)CmsCnPosting.Searches.GetByPath(strTargetChannelPath);
Template connectedTemplate = (Template)CmsCnPosting.Searches.GetByPath(strConnectedTemplatePath);
if(sourcePosting !=null && targetChannel !=null && connectedTemplate !=null)
{
bool pPosting = sourcePosting.CanSetProperties;
bool cT1 = targetChannel.CanCreatePostings;
if(pPosting && cT1)
{
Posting pNewPosting = (Posting) targetChannel.CreateConnectedPosting(connectedTemplate, sourcePosting);
pNewPosting.DisplayName = strNewPostingName;
CmsCnPosting.CommitAll();
MessageBox.Show(this,"A connected posting has been created successfully","Success");
}
}
else
{
MessageBox.Show(this,"You do not have rights to change posting properties or create a posting","Connected Posting");
return;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message + " " + ex.Source, "Error creating a connected posting");
}
CmsCnPosting.Dispose();
back to the top
Modification Type: | Major | Last Reviewed: | 7/19/2004 |
---|
Keywords: | kbHOWTOmaster kbSample kbhowto KB840148 kbAudDeveloper |
---|
|