Site structure
Version 5.x > Site structure > Document URL restricted to 50 characters View modes: 
User avatar
Member
Member
phansen-fph - 3/22/2012 4:06:17 PM
   
Document URL restricted to 50 characters
Hi there,

I have a bunch of documents to import into Kentico CMS and some with file names longer than 50 characters in length. When imported, the document name and file name are complete, however the URL for the document is cut off at 50 characters in length.

Is there an easy way to increase the allowable length of characters for URLs in Kentico?

Thanks.

User avatar
Member
Member
kentico_edwardh - 3/22/2012 4:15:10 PM
   
RE:Document URL restricted to 50 characters
The following definition of the textbox in the underlying aspx page:
~\CMSModules\Content\CMSDesk\Properties\Alias_List.aspx

<asp:TextBox ID="txtAlias" runat="server" CssClass="TextBoxField" MaxLength="50" />

You can change it there to allow more characters, or set it in the codebehind, where you would try to get the settings key value from webconfig, and optionally default the value to standard 50 chars. There are more limits that are put together. Basic ones are for NodeAliasPath - whole alias path must be less than 450 chars long, and then NodeAlias (one level). There's also a Document name field length and DocumentUrlPath (that's used as live url). Generally, you can have longer names in URL by manually setting "Custom URL Path", which is also good for trimming the really long URLs in the desired place (and not in the middle of the word...).

Following two keys that can be used in web.config file (and are described at http://devnet.kentico.com/docs/devguide/web_config_parameters.htm) and the related comments should explain this a little bit:
CMSMaxNodeAliasLength

Maximal length of a document's node alias. The default value is 50 characters and larger names are trimmed. This key can be used to increase the length - useful for long node aliases. If you use the key, you also need to set the size of the 'NodeAlias' column in the 'CMS_Tree' database table to the same value. However, the maximal length of 'Node alias path' is 450 characters, so documents deep in the tree will have the 'Node alias path' trimmed anyway.

The default value is 50.

example of usage:
<add key="CMSMaxNodeAliasLength" value="120" />

CMSMaxNodeNameLength

Maximal length of a document's node name. The default value is 100 characters and larger names are trimmed. This key can be used to increase the length - useful for long node names. If you use the key, you also need to set the size of the 'NodeName' column in the 'CMS_Tree' database table to the same value.

The default value is 100.

You might be thinking about using "Use name path for URL path" setting. This is good, however the same trimming as for NodeAlias is performed here - using CMSMaxNodeAliasLength limit.

The best thing would be probably to make some strings of particular length 51 / 101 and so on ... and after setting the keys (and DB fields), checking if the behavior of shortening suits your needs.

Best Regards,
Edward Hillard

User avatar
Member
Member
sini.sivasankaran-solarwinds - 11/2/2012 2:09:20 AM
   
RE:Document URL restricted to 50 characters
Hi Edward

I have tried changing the default length in web.config and tables as below after referring this post and http://devnet.kentico.com/docs/devguide/index.html?web_config_parameters.htm

When I try to enter document name with 150 characters , getting this error.
An error occurred when saving data:[DataConnection.HandleError]: Query: Proc_CMS_Tree_MoveNodeFirst: caused exception: String or binary data would be truncated. The statement has been terminated.

What could be missing?

Config changes were
<add key="CMSMaxNodeNameLength" value="150" />
<add key="CMSMaxNodeAliasLength" value="150" />
and table changes where

ALTER TABLE dbo.CMS_Tree
ALTER COLUMN NodeName NVARCHAR(150) NOT NULL;

ALTER TABLE dbo.CMS_Tree
ALTER COLUMN NodeAlias NVARCHAR(150) NOT NULL;

ALTER TABLE dbo.CMS_Document
ALTER COLUMN DocumentName NVARCHAR(150) NOT NULL;

ALTER TABLE dbo.CMS_VersionHistory
ALTER COLUMN VersionDocumentName NVARCHAR(150) NOT NULL;

Thanks,
Sini

User avatar
Member
Member
sini.sivasankaran-solarwinds - 11/2/2012 2:10:11 AM
   
RE:Document URL restricted to 50 characters
I have also changed the file Alias_List.aspx
<cms:CMSTextBox ID="txtAlias" runat="server" CssClass="TextBoxField" MaxLength="150" />

User avatar
Member
Member
kentico_edwardh - 11/12/2012 7:32:45 PM
   
RE:Document URL restricted to 50 characters
Hello,

You will more than likely have to update the stored procedure. The Proc_CMS_Tree_MoveNodeFirst stored procedure calls another stored procedure "proc_CMS_Tree_InitNodeOrders" which has the following values defined.
BEGIN
/* Declare the selection table */
DECLARE @nodesTable TABLE (
NodeID int,
NodeOrder int,
NodeName nvarchar(100),
NodeAlias nvarchar(50)
);

Please check the value for this stored procedure to see if they are set to your new raised values.

Best Regards,
Edward Hillard

User avatar
Member
Member
oohoangthienoo-gmail - 8/13/2013 11:46:27 AM
   
RE:Document URL restricted to 50 characters
I also have the error condition: The Proc_CMS_Tree_MoveNodeFirst stored procedure calls another stored procedure "proc_CMS_Tree_InitNodeOrders" which has the following values defined. but I'm using version 6.
you may helps me how to handle this error nhu the that
Thanks.

User avatar
Member
Member
kentico_edwardh - 8/14/2013 1:07:25 PM
   
RE:Document URL restricted to 50 characters
Hello,

Have you updated these stored procedures as the previous post has suggested? What is the error message you are encountering?

Best Regards,
Edward Hillard