How can I stop authors from saving pages with identical names?
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 > How can I stop authors from saving pages with identical names?




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

    How can I stop authors from saving pages with identical names?  
Morten Petterĝe


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


 
04-27-04 05:36 PM

Hi,

I have told all authors that we must be careful not to enter duplicate
posting names in one channel. This will break a lot of language switching
code that I have on my multilingual website.

Is there an easy ( or hard for that matter )  way of implementing a check
when the user clicks "Save New Page" so that I can throw a simple
PublishingException or something if a page with the same name already
exists?

Any help is appreciated.


Thanks,

Morten







[ Post a follow-up to this message ]



    Re: How can I stop authors from saving pages with identical names?  
Stefan [MSFT]


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


 
04-27-04 07:36 PM

Hi Morten,

I would suggest to either implement a custom save console action and test if
a posting with identical name exits.

Cheers,
Stefan.

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


"Morten Petterĝe" <morten@imano.nospam (remove the spam, leave the no)>
wrote in message news:e$fgx$GLEHA.624@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> I have told all authors that we must be careful not to enter duplicate
> posting names in one channel. This will break a lot of language switching
> code that I have on my multilingual website.
>
> Is there an easy ( or hard for that matter )  way of implementing a check
> when the user clicks "Save New Page" so that I can throw a simple
> PublishingException or something if a page with the same name already
> exists?
>
> Any help is appreciated.
>
>
> Thanks,
>
> Morten
>
>







[ Post a follow-up to this message ]



    Re: How can I stop authors from saving pages with identical names?  
Morten Petterĝe


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


 
04-30-04 12:35 PM

Hi again,

I have tried to do this by implementing an eventhandler on the created
event. But when I check for the name of the posting (e.Target.Name), this
always returns the name of the Template. What do I do to get the actual name
that the user has entered for this posting?


Thanks,

Morten

"Stefan [MSFT]" <stefang@online.microsoft.com> wrote in message
news:uAzrlfILEHA.556@tk2msftngp13.phx.gbl...
> Hi Morten,
>
> I would suggest to either implement a custom save console action and test
if
> a posting with identical name exits.
>
> Cheers,
> Stefan.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
>
> "Morten Petterĝe" <morten@imano.nospam (remove the spam, leave the no)>
> wrote in message news:e$fgx$GLEHA.624@TK2MSFTNGP11.phx.gbl... 
switching[vbcol=seagreen] 
check[vbcol=seagreen] 
>
>







[ Post a follow-up to this message ]



    Re: How can I stop authors from saving pages with identical names?  
Stefan [MSFT]


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


 
04-30-04 06:37 PM

Hi Morten,

the name is applied with a changed event handler later.
But the name is already available in a Request.Form variable (you need to
check which one as I don't have the info avail at the moment).
More elegant is the solution with a modified console action.

Cheers,
Stefan.

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


"Morten Petterĝe" <morten@imano.nospam (remove the spam, leave the no)>
wrote in message news:OFdcODqLEHA.1032@TK2MSFTNGP12.phx.gbl...
> Hi again,
>
> I have tried to do this by implementing an eventhandler on the created
> event. But when I check for the name of the posting (e.Target.Name), this
> always returns the name of the Template. What do I do to get the actual
name
> that the user has entered for this posting?
>
>
> Thanks,
>
> Morten
>
> "Stefan [MSFT]" <stefang@online.microsoft.com> wrote in message
> news:uAzrlfILEHA.556@tk2msftngp13.phx.gbl... 
test[vbcol=seagreen]
> if 
> rights. 
> switching 
> check 
>
>







[ Post a follow-up to this message ]



    Re: How can I stop authors from saving pages with identical names?  
Mikey_Doc


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


 
05-12-04 01:20 AM

Hi Morten

The solution we use (Ok its not particularly elegant) is t0 catch the
propertyChanging event in the Global.aspx file.

If the user has typed a duplicate file name we append the code with
the date and the 'XXXX'.  The console checks current posting name and
if it sees the XXXX it generates a message saying that this is a
duplicate posting (Even though it isn't as the name has been changed.
As I say not particularly elegant but it does the job.

(Here the code is checking he file name but a minor change would let
it check the display name)

Please note the minimalist approach to comments.

Mikey

Protected Sub CmsPosting_PropertyChanging(ByVal sender As Object,
ByVal e As PropertyChangingEventArgs)
Dim p As Posting
If e.Target().getType().Name = "Posting" Then
p = e.Target
Dim propName As String = e.PropertyName
Dim tname As String = ""
If propName = "Name" Then
If CheckForDuplicateName(p, e.PropertyValue) Then
e.PropertyValue = e.PropertyValue +
DateTime.Now.ToString("dd-MMM-yyyy HH-mm-ss") & "xxxx"
End If
End If
End If
End Sub

Private Function CheckForDuplicateName(ByVal p As Posting, ByVal
val As String) As Boolean
Dim ch As Microsoft.ContentManagement.Publishing.Channel =
CmsHttpContext.Current.Channel()
Dim post As Posting
post = ch.Postings(val)
If Not post Is Nothing Then
Return True
End If
Return False
End Function




"Stefan [MSFT]" <stefang@online.microsoft.com> wrote in message news:<#cRCYUtLEHA.624@TK
2MSFTNGP11.phx.gbl>...[vbcol=seagreen]
> Hi Morten,
>
> the name is applied with a changed event handler later.
> But the name is already available in a Request.Form variable (you need to
> check which one as I don't have the info avail at the moment).
> More elegant is the solution with a modified console action.
>
> Cheers,
> Stefan.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>
>
> "Morten Petterĝe" <morten@imano.nospam (remove the spam, leave the no)>
> wrote in message news:OFdcODqLEHA.1032@TK2MSFTNGP12.phx.gbl... 
>  name 
>  test
>  if 
>  rights. 
>  switching 
>  check 





[ Post a follow-up to this message ]



    Re: How can I stop authors from saving pages with identical names?  
Sandeep


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


 
06-11-04 11:49 PM

Here is another possible solution that actually cancels
the save:

In the global.asa:

public void CmsPosting_Creating( Object sender,
CreatingEventArgs e )
{
string postingName = Request.Form
["WBC_fieldNewPageName"];
if (IsDuplicatePosting(postingName.Trim()))
{
e.Cancel = true;
}
}
private bool IsDuplicatePosting(string postingName)
{
Logging.LogTrace(Logging.MethodCalledString);
try
{
foreach (Posting p in
currentCmsContext.Channel.Postings)
{
if (p.Name==postingName) return
true;
}
}
catch
{
return true;
}
return false;
}

To return a friendly error to the user as a replacement
for the default error message displayed, add the
following in the console control pre-render event:

private void Console1_PreRender(object sender,
System.EventArgs e)
{
if (ErrorModeContainerFailedCreate1.Visible)
{
if
(ErrorModeContainerFailedCreate1.Error.Exception.Message.I
ndexOf("custom event handler")!=-1)
{
errorMessage = "Save failed due
to duplicate name";
}
else
errorMessage =
ErrorModeContainerFailedCreate1.Error.Exception.Message;
}
}





[ Post a follow-up to this message ]



    Re: How can I stop authors from saving pages with identical names?  
Sandeep


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


 
06-21-04 04:03 AM

Here is another possible solution that actually cancels
the save:

In the global.asa:

public void CmsPosting_Creating( Object sender,
CreatingEventArgs e )
{
string postingName = Request.Form
["WBC_fieldNewPageName"];
if (IsDuplicatePosting(postingName.Trim()))
{
e.Cancel = true;
}
}
private bool IsDuplicatePosting(string postingName)
{
Logging.LogTrace(Logging.MethodCalledString);
try
{
foreach (Posting p in
currentCmsContext.Channel.Postings)
{
if (p.Name==postingName) return
true;
}
}
catch
{
return true;
}
return false;
}

To return a friendly error to the user as a replacement
for the default error message displayed, add the
following in the console control pre-render event:

private void Console1_PreRender(object sender,
System.EventArgs e)
{
if (ErrorModeContainerFailedCreate1.Visible)
{
if
(ErrorModeContainerFailedCreate1.Error.Exception.Message.I
ndexOf("custom event handler")!=-1)
{
errorMessage = "Save failed due
to duplicate name";
}
else
errorMessage =
ErrorModeContainerFailedCreate1.Error.Exception.Message;
}
}





[ Post a follow-up to this message ]



    Re: How can I stop authors from saving pages with identical names?  
Stefan [MSFT]


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


 
06-26-04 03:49 PM

Hi Teri,

yes.
See the following sample:
http://www.gotdotnet.com/Community/...e7-56dd30bb89fe

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
--------------------------------


"Teri" <Teri@discussions.microsoft.com> wrote in message
news:E774EC69-CD46-4792-8103-17F5898DF1A3@microsoft.com...
> I tried to post a new message but... the drop down for the required "post
in discussion group" wouldn't populate.  My question is similar to this
topic.
>
> Is it possible to populate the Name and Display Name fields on the Save
New Page popup?  On specific templates (Ex: news article postings) we would
like the name of the page to begin with the release date of the article
(YYYYMMDD).  We can then sort the articles by name to get them in date
order.  We are able to rename the page on re-edit save.  We have also been
able to populate the hidden variable WBC_fieldNewPageName via javascript.
Unfortunately it looks like the Save New Page popup is not reading this
hidden variable.  We are out of ideas.  Any assitance is appreciated.[vbcol=seagreen]
>
> Thanks,
> Teri
>
> "Sandeep" wrote:
> 







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:17 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