1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Page name in lowercase

Page name in lowercase

5 posts, 0 answered
  1. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    18 Dec 2008
    Link to this post
    Hi,

    How I can make page name always in lowercase?

    For example, user write - ProductPage. But the page in database have name productpage, or My_First_Page => my_first_page.

    Thanks,
    Anton.

  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    18 Dec 2008
    Link to this post
    Hello Anton,

    In case you need it, there is a column called LoweredName in sf_PageBase table where the name of the page is stored as lower case.

    Actually, there is an easy way to convert all pages to use lower cases. Here is what I suggest you to use:
    1. Open your global.asax file (located in the application root directory) and subscribe to the following event on Application_Start:
    void Application_Start(object sender, EventArgs e)  
     { 
            Telerik.Cms.CmsManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(CmsManager_Executing)
     } 
     

    2. Here's the CmsManager.Executing event:
    void CmsManager_Executing(object sender, Telerik.ExecutingEventArgs e) 
       if (e.CommandName == "Publish"
       { 
           Telerik.Cms.ICmsPage page = e.CommandArguments as Telerik.Cms.ICmsPage; 
           page.Name = page.Name.ToLower();
           //page.MenuName = page.MenuName.ToLower();
        } 

    I will explain you what this code does.

    When you create a page, the Cms Manager is being executed. We subscribe to this event, and we take the command - if it is Publish, then the user is publishing a page. What we want is to change the page name to lower on Publish. We take the item (page) which the user is publishing from the arguments, and change its name to lower case.
    Please note that the Menu Name (the one visible in the page treeview) is left as it is. You can change this page property in the same method, by uncommenting the line above.

    I really hope that this helps you. Let me know if there is anything else we can do for you.



    Regards,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    18 Dec 2008
    Link to this post
    Hello Georgi,

    Thanks for answer!

    But I have a problem:

    You cannot change a value of an object that is not in transaction.


    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
     
    Exception Details: Nolics.ORMapper.Base.NolnetException: You cannot change a value of an object that is not in transaction. 
     
    Source Error: 
     
    Line 73:         { 
    Line 74:             Telerik.Cms.ICmsPage page = e.CommandArguments as Telerik.Cms.ICmsPage; 
    Line 75:             page.Name = page.Name.ToLower(); 
    Line 76:             //page.MenuName = page.MenuName.ToLower(); 
    Line 77:         } 


    Thanks,
    Anton.
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    18 Dec 2008
    Link to this post
    Hello Anton,

    Could you please try with this approach:
    if (e.CommandName == "UpdatePage" || e.CommandName == "CreatePage"

    instead of
    if (e.CommandName == "Publish")  

    It should work with my previous solution though. The object is in transaction anyway. I tested with Sitefinity 3.5SP1 standard and community and there were no problems. I will have to investigate why this happens.

    Let me know about the results this time.







    Greetings,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    19 Dec 2008
    Link to this post
    Hello Georg,

    Thanks, it works!

    Best regards,
    Anton.
Register for webinar
5 posts, 0 answered