 |
|
 |
|
10-08-04 12:48 PM
This is driving me up the wall.
Suppose the channel structure is as follows:
\Channel A
postings A
\Channel B
postings B
\Channel C
postings C
If a user deletes a posting C, I want the program to climb up deleting
postings C, Channel C, postings B, and Channel B.
What will be left is
\Channel A
postings A
Try as I might, the best I could do is delete everything I wanted (I checked
in the Site Manager}, but the program would crash on an error.
I've tried to do this in CmsPosting_Deleting or CmsPosting_Deleted or both.
I'm at the end of my wits.
Could someone write a quick and dirty (preferably clean) sample code that
would accomplish the exercise?
Thank you.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
10-08-04 10:48 PM
Stefan,
This is a modified and stripped-down version:
public void CmsPosting_Deleted( Object sender, ChangedEventArgs e )
{
CmsContext cmsContext = e.Context;
Posting pPageToDelete = e.Target as Posting;
Channel cChannelToDelete;
if ( pPageToDelete != null )
{
cChannelToDelete = pPageToDelete.Parent;
}
if ( cChannelToDelete.Postings.Count > 0 )
{
foreach ( Posting pPage in cChannelToDelete.Postings )
{
if ( pPage.Name.ToString() == pPageToDelete.Name.ToString() )
{
cmsContext.CommitAll();
}
else
{
pPage.Delete();
}
}
}
else
{
if ( chnChannelToDelete != null )
{
chnChannelToDelete.Delete();
cmsContext.CommitAll();
}
}
} // end
If you have a structure
\Channel A
postings A
\Channel B
postings B
the program is meant to delete
\Channel B
postings B
It does. At least, I don't see the sub-tree in the Site Manager.
But I get a rude error message:
"Object has been deleted. An attempt was made to access the properties or
methods of an object that was deleted by the current session."
I'm open to any suggestions/solutions. If web author console code is
available, I'll take it.
Thank you.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
10-08-04 10:48 PM
Ah!
Ok, the problem is that you need to redirect to a valid URL after the
deletion.
The URL you will get redirected to is the parent channel - which just has
been deleted.
Adding a manualy response.redirect (e.g. to the root channel) should resolve
this.
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
--------------------------------
"bill tie" <billtie@discussions.microsoft.com> wrote in message
news:108C9FC1-7C8A-412B-BD0A-39D4BF0D2120@microsoft.com...
>
> Stefan,
>
> This is a modified and stripped-down version:
>
>
> public void CmsPosting_Deleted( Object sender, ChangedEventArgs e )
> {
> CmsContext cmsContext = e.Context;
> Posting pPageToDelete = e.Target as Posting;
> Channel cChannelToDelete;
>
> if ( pPageToDelete != null )
> {
> cChannelToDelete = pPageToDelete.Parent;
> }
>
> if ( cChannelToDelete.Postings.Count > 0 )
> {
> foreach ( Posting pPage in cChannelToDelete.Postings )
> {
> if ( pPage.Name.ToString() == pPageToDelete.Name.ToString() )
> {
> cmsContext.CommitAll();
> }
> else
> {
> pPage.Delete();
> }
> }
> }
> else
> {
> if ( chnChannelToDelete != null )
> {
> chnChannelToDelete.Delete();
> cmsContext.CommitAll();
> }
> }
> } // end
>
> If you have a structure
>
> \Channel A
> postings A
> \Channel B
> postings B
>
> the program is meant to delete
>
> \Channel B
> postings B
>
> It does. At least, I don't see the sub-tree in the Site Manager.
>
> But I get a rude error message:
>
> "Object has been deleted. An attempt was made to access the properties or
> methods of an object that was deleted by the current session."
>
> I'm open to any suggestions/solutions. If web author console code is
> available, I'll take it.
>
> Thank you.
>
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
10-08-04 10:48 PM
Angus,
Congratulations on your freshly acquired MVP-ship.
> Why do you want to remove the channel and parent channel if
> a posting is deleted?
Call me meticulous if you will. In hindsight, I didn't have to code this
feature for it may never ever be used on the website we're developing. Yet,
this is the rationale.
If a user deletes the "last" posting in a channel, there is still an index
page (MVPs call it a channel-rendering page).
If the channel is not re-used for a long time, the index page should display
text different from usual. We didn't think it was nice. It seemed easier
just to delete the index page.
If the index page is gone, why have the channel? So let's delete the channe
l.
However, the parent channel of the deleted channel has a special page in it.
The special page depends on the child channel.
Well, let's delete the special page. If we delete the special page, why
have an empty channel?
Thank goodness, there are no more channels and pages to delete. This note
would get into an endless loop.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
 |
|
 |
|
10-08-04 10:48 PM
Actually you might end of the on the /Channels object left.
This cannot be deleted. Thanks god! ;-)
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
--------------------------------
"bill tie" <billtie@discussions.microsoft.com> wrote in message
news:79295A34-B46F-4F5B-9BF8-BF5921EE6A11@microsoft.com...
>
> Angus,
>
> Congratulations on your freshly acquired MVP-ship.
>
>
> Call me meticulous if you will. In hindsight, I didn't have to code this
> feature for it may never ever be used on the website we're developing.
Yet,
> this is the rationale.
>
> If a user deletes the "last" posting in a channel, there is still an index
> page (MVPs call it a channel-rendering page).
>
> If the channel is not re-used for a long time, the index page should
display
> text different from usual. We didn't think it was nice. It seemed easier
> just to delete the index page.
>
> If the index page is gone, why have the channel? So let's delete the
channel.
>
> However, the parent channel of the deleted channel has a special page in
it.
> The special page depends on the child channel.
>
> Well, let's delete the special page. If we delete the special page, why
> have an empty channel?
>
> Thank goodness, there are no more channels and pages to delete. This note
> would get into an endless loop.
>
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
10-16-04 02:13 AM
You ~could~ just create your channel listing page to check and see if there
are postings within a channel before displaying it... so it will no longer
be there.
-AC
"bill tie" <billtie@discussions.microsoft.com> wrote in message
news:79295A34-B46F-4F5B-9BF8-BF5921EE6A11@microsoft.com...
>
> Angus,
>
> Congratulations on your freshly acquired MVP-ship.
>
>
> Call me meticulous if you will. In hindsight, I didn't have to code this
> feature for it may never ever be used on the website we're developing.
> Yet,
> this is the rationale.
>
> If a user deletes the "last" posting in a channel, there is still an index
> page (MVPs call it a channel-rendering page).
>
> If the channel is not re-used for a long time, the index page should
> display
> text different from usual. We didn't think it was nice. It seemed easier
> just to delete the index page.
>
> If the index page is gone, why have the channel? So let's delete the
> channel.
>
> However, the parent channel of the deleted channel has a special page in
> it.
> The special page depends on the child channel.
>
> Well, let's delete the special page. If we delete the special page, why
> have an empty channel?
>
> Thank goodness, there are no more channels and pages to delete. This note
> would get into an endless loop.
>
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
|
Sponsored Links |
 |
 |
|
|
 |
All times are GMT. The time now is 12:31 PM. |
 |
|
|
 |
|
 |
|
|
 |
|
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
|
 |
|
 |
|