AP - How to get "Add to Area" to disappear

Permalink
I've been chatting with some guys from the community on how to allow a group to edit all sections but disable the "add to area" for everyone but the super admin.

They came up with this...

$u = new User();
if (!$u->isSuperUser()) { $a->setBlockLimit($a-> getTotalBlocksInArea($c)); }

Which works awesome but for some reason I'm still getting the "add to area" still but its not showing anything when I click on it... Here is a screenshot.

http://imgur.com/e4gy9

Any thoughts on how to get rid of this?

bryanlewis
View Replies:
bryanlewis replied on at Permalink Reply
bryanlewis
Any help on this would be great. Thanks!
bryanlewis replied on at Permalink Reply
bryanlewis
I'm having the same problem as @kirkroberts and @sarah3585 on this thread...

http://www.concrete5.org/developers/bugs/5.6.0.1/set-block-limit-no...

I would reply to the thread but it looks like its closed...
HeavyPhoton replied on at Permalink Reply
HeavyPhoton
If anyone is still interested in a solution for 5.6 I put together a js function that removes the "Add Too.." option when the block limit is reached. Very handy for client templates.

This is the code:
/* ENFORCE 'CONCRETE5 AREA' BLOCK LIMITS
  ======================================= */
    // ensure that the "Add Too.." functionality is disabled when block limits are reached.
    // function is called with no parameters but is then recursively polled passing back
    // two arrays of 'concrete area' data
    hasScannedBlockLimits = false;
    function enforceBlockLimits ( recAreas = [], recLimits = [] ) {
      // scan page for limited areas once
      if(!hasScannedBlockLimits) {
        var areaElements = getLimitedAreas();
        var areas  = areaElements[0];
        var limits = areaElements[1];
        hasScannedBlockLimits = true;
      }
      // limited areas have been passed in recursively


This is how I use it:

First I set the block limits using "data-block-limit" on a containing div:
<div class="main-nav" data-block-limit="1">
  <?php  
    $a = new GlobalArea('HeaderGlobal');
    $a->display($c);
  ?>
</div>


I use the following to signal that a page is in 'edit mode':
<body class="<?php  if ($c->isEditMode()) { ?>edit-mode<?php  } ?>">


Then I simply run enforceBlockLimit( ) on page load, but only in 'edit mode':
$( document ).ready(function() {  
  // enforce concrete5 area block limits
  if ( $( 'body' ).hasClass( 'edit-mode' ) )    
    enforceBlockLimits(  ); 
});


This is all done without actually using "$a->setBlockLimit(1);", rather I am just disabling the functionality cosmetically. I use it all the time for client templates, let me know what you think.