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

Forums / Developing with Sitefinity / Set ContentPlaceHolder not editable at page edit level

Set ContentPlaceHolder not editable at page edit level

2 posts, 0 answered
  1. Liam
    Liam avatar
    18 posts
    Registered:
    30 Jun 2010
    02 Sep 2010
    Link to this post
    Hi,

    I'm using version 3.7 and I'm after a way to make ContentPlaceHolder containers not accessable at the page edit level. That is, I have some ContentPlaceHolder in which I want to place controls at the template level, but I do not want cms users to be able to place further controls in those same containers at page level or to be able to remove the existing controls.

    Now I could do something like the following in the template master page:

    if(
       ((CmsPageBase)Page).PageMode!=CmsPageMode.Live &&
       !HttpContext.Current.Request.Url.AbsolutePath.Contains(".template")
      )
    {
       ContentPlaceHolder _somePlaceHolder = (ContentPlaceHolder)(this.Page.Master).FindControl("somePlaceHolderId");
       if( _somePlaceHolder!=null )
       {
          _somePlaceHolder.Visible = false;
       }
    }
    So that in edit or preview mode for a page the targeted ContentPlaceHolder is not visible. However, it still appears in the list of containers in which one can add controls, it just doesn't render on the page. Actually that is the opposite of the behaviour I would like to achieve. i.e. I want the controls placed in the ContentPlaceHolder at template level to render on the page in edit mode, I just don't want those ContentPlaceHolders to appear in the list of containers in which a user can add controls at page level edit mode.

    Does that make sense? Is what I'm after possible?

    Thanks.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Sep 2010
    Link to this post
    Hello Liam,

    1. You can use css and java script to disable drag and drop of the controls over a given holder instead of hiding the entire holder. by doing so you will be able to see the control in edit mode

    sample code

       <style>
        .locker
        {
            width: 100%;
            height: 20px;
            background-color: black;
            position: absolute;
            left: 0px;
            top: 0px;
        }
        </style>
    </body>
    </html>
    <script  type="text/javascript">
     
        function pageLoad() {
            var i = 0;
            var holder = $("#" + "<%= cphContent.ClientID %>" + "_des" + i)
            $("#ctl00_theWrapper").append('<div class="locker"></div>');
            $(".locker").css('opacity', '0.1')
            $(".locker").height($(holder).height() + 'px');
            $(holder).live('mouseover', function() {
                $('.ZoneDesignerFullSel').hide();
            })
        }
         
    </script>


    2. You can hide "select a container" by accessing the toobar and DropDown inside it.  You can take a look at this post.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered