| Mei Ying [MVP] 2004-11-04, 8:46 pm |
| Hi
To solve the current error, use the Count property of the
collection, like this:
for (int i=0; i < superPosting.Placeholders.Count; i++)
And for copying the contents of the placeholder, have a
look at this entry in Stefan's blog which includes some
sample code:
http://weblogs.asp.net/stefan_gossn...e/2004/04/24/11
9546.aspx
In case you change your mind about connected templates,
this solution does the same job without all the code:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-
8&c2coff=1&selm=uS5p0kvmCHA.456%40TK2MSFTNGP08
HTH
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Contact: meiyinglim@hotmail.com
---
>-----Original Message-----
>Is there a way to populate a posting in the "site root
>channel" from a posting in one of its sub-channels?
>
>For example.
>
>"www.mysite.com" is root channel
>
>"aboutus" is sub channel
>
>I want to populate a posting in the "www.mysite.com"
>channel from a posting in the "aboutus" channel, without
>using connected templates.
>
>Here's what I have so far...
>
>// Get the posting you're copying from
>Posting superPosting =
>CmsHttpContext.Current.Channel.Postings["standAlone"];
>// Get the posting you're copying to
>Posting copyPosting =
>CmsHttpContext.Current.RootChannel.Postings["notAlone"];
>// Loop through the placeholders in the first posting
>for (int i=0; i < superPosting.Placeholders; i++)
> {
> copyPosting.Placeholders[i] =
>superPosting.Placeholders[i];
> }
>
>
>From that I get an error on the "<" operator saying it
>can be applied to a CMS posting collection.
>
>Can anyone help?
>
> Thanks!
>
>
>.
>
|