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?
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](/files/avatars/488.jpg)
Any help on this would be great. Thanks!
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...
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...
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:
This is how I use it:
First I set the block limits using "data-block-limit" on a containing div:
I use the following to signal that a page is in 'edit mode':
Then I simply run enforceBlockLimit( ) on page load, but only in 'edit mode':
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.
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
Viewing 15 lines of 58 lines. View entire code block.
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.