programmatically set properties
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Content Management Server > programmatically set properties




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    programmatically set properties  
Dune


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-23-04 10:51 PM

How can I set the properties for a placeholder definition through code?

I've created a custom placeholder by inheriting from HtmlPlaceholder but
would like to restrict the user by setting the properties of the
PlaceholderDefinition associated with my custom placeholder, that is, I woul
d
like to control AllowHyperlinks, AllowLinebreaks, Formatting,
AllowAttachments etc programmatically.

Cheers





[ Post a follow-up to this message ]



    Re: programmatically set properties  
Stefan [MSFT]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-24-04 07:48 AM

Hi Dune,

here is some code that shows how to create a template definition with a
placeholder definition programmatically.
It also shows how the proeprties of the placeholder definition are set.

// Get the CMS application context
CmsApplicationContext cmsContext = new CmsApplicationContext();

// Make sure to set the context to be in the Update mode (which means you
can write
// back to CMS using PAPI.
cmsContext. AuthenticateAsCurrentUser(PublishingMode
.Update);

TemplateGallery tplGallery = cmsContext.RootTemplateGallery;
// template stuff

Template newTemplate = tplGallery.CreateTemplate();
newTemplate.SourceFile = "/Test/MyTemplate.aspx" ;
newTemplate.Name = "MyTemplate";

// Create new HtmlPlaceholder Definition in the Template
HtmlPlaceholderDefinition phDef =
newTemplate.CreatePlaceholderDefinition( new HtmlPlaceholderDefinition() )
as HtmlPlaceholderDefinition;
phDef.Name = "MyPhDef";
phDef.AllowAttachments = true;
phDef.AllowHyperlinks = false;
phDef.AllowLineBreaks = false;
phDef.Formatting =
HtmlPlaceholderDefinition.SourceFormatting.FullFormatting;

CustomPropertyDefinition cpDef =
newTemplate.CreateCustomPropertyDefinition();
cmsContext.CommitAll();  // stefang: this commit is required to avoid
duplicate definitions. Bug?
cpDef.Name = "MyCustPropDef" ;
cpDef.DefaultValue = "MyValue" ;

newTemplate.Submit();

// end template stuff

cmsContext.CommitAll() ;


Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...>
MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...nagement+Server
MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"Dune" <Dune@discussions.microsoft.com> wrote in message
news:90614490-A554-4F30-AA83-076D6CCA702D@microsoft.com...
> How can I set the properties for a placeholder definition through code?
>
> I've created a custom placeholder by inheriting from HtmlPlaceholder but
> would like to restrict the user by setting the properties of the
> PlaceholderDefinition associated with my custom placeholder, that is, I
would
> like to control AllowHyperlinks, AllowLinebreaks, Formatting,
> AllowAttachments etc programmatically.
>
> Cheers







[ Post a follow-up to this message ]



    Re: programmatically set properties  
Dune


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-26-04 10:52 PM

Thanks Stefan,

That's exactly what I needed.

Cheers, Dune

"Stefan [MSFT]" wrote:

> Hi Dune,
>
> here is some code that shows how to create a template definition with a
> placeholder definition programmatically.
> It also shows how the proeprties of the placeholder definition are set.
>
>    // Get the CMS application context
>    CmsApplicationContext cmsContext = new CmsApplicationContext();
>
>    // Make sure to set the context to be in the Update mode (which means y
ou
> can write
>    // back to CMS using PAPI.
>    cmsContext. AuthenticateAsCurrentUser(PublishingMode
.Update);
>
>    TemplateGallery tplGallery = cmsContext.RootTemplateGallery;
>    // template stuff
>
>    Template newTemplate = tplGallery.CreateTemplate();
>    newTemplate.SourceFile = "/Test/MyTemplate.aspx" ;
>    newTemplate.Name = "MyTemplate";
>
>    // Create new HtmlPlaceholder Definition in the Template
>    HtmlPlaceholderDefinition phDef =
> newTemplate.CreatePlaceholderDefinition( new HtmlPlaceholderDefinition() )
> as HtmlPlaceholderDefinition;
>    phDef.Name = "MyPhDef";
>    phDef.AllowAttachments = true;
>    phDef.AllowHyperlinks = false;
>    phDef.AllowLineBreaks = false;
>    phDef.Formatting =
> HtmlPlaceholderDefinition.SourceFormatting.FullFormatting;
>
>    CustomPropertyDefinition cpDef =
> newTemplate.CreateCustomPropertyDefinition();
>    cmsContext.CommitAll();  // stefang: this commit is required to avoid
> duplicate definitions. Bug?
>    cpDef.Name = "MyCustPropDef" ;
>    cpDef.DefaultValue = "MyValue" ;
>
>    newTemplate.Submit();
>
>    // end template stuff
>
>    cmsContext.CommitAll() ;
>
>
> Cheers,
> Stefan.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>
> MCMS FAQ:
> http://download.microsoft.com/downl...
a/MCMS+2002+-+(complete)+FAQ.htm
> MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
> MCMS Sample Code:
> http://www.gotdotnet.com/community/...nagement+Server
> MCMS Whitepapers and other docs:
> http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
> --------------------------------
>
>
> "Dune" <Dune@discussions.microsoft.com> wrote in message
> news:90614490-A554-4F30-AA83-076D6CCA702D@microsoft.com... 
> would 
>
>
>





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:54 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register