Remove element by value from array
Permalink
Hello everyone,
I want to remove an element by value from the $blockTypes array.
The block_area_add_new.php is containing this code:
This code is handling all the addons in the "Add Block" list.
I want to remove the element with the value where $bt->getBlockTypeName() is "HTML" from the $blockTypes array.
Is that possible ?
So far I have been trying doing this by using this function:
But this function removes elements by array index. This is a problem because if I add a new addon, this function might remove the wrong addon.
Solution:
A filter. :)
I want to remove an element by value from the $blockTypes array.
The block_area_add_new.php is containing this code:
if (count($blockTypes) > 0) { foreach($blockTypes as $bt) { $btIcon = $ci->getBlockTypeIconURL($bt); ?> <li class="ccm-block-type ccm-block-type-available"> <a onclick="ccmBlockTypeResetKeys()" dialog-on-destroy="ccmBlockTypeMapKeys()" class="dialog-launch ccm-block-type-inner" dialog-on-close="ccm_blockWindowAfterClose()" dialog-modal="false" dialog-width="<?php echo $bt->getBlockTypeInterfaceWidth()?>" dialog-height="<?php echo $bt->getBlockTypeInterfaceHeight()?>" style="background-image: url(<?php echo $btIcon?>)" dialog-title="<?php echo t('Add')?> <?php echo $bt->getBlockTypeName()?>" href="<?php echo REL_DIR_FILES_TOOLS_REQUIRED?>/add_block_popup.php?cID=<?php echo $c->getCollectionID()?>&btID=<?php echo $bt->getBlockTypeID()?>&arHandle=<?php echo urlencode($a->getAreaHandle())?>"><?php echo $bt->getBlockTypeName()?></a> <div class="ccm-block-type-description" id="ccm-bt-help<?php echo $bt->getBlockTypeID()?>"><?php echo $bt->getBlockTypeDescription()?></div> </li>
This code is handling all the addons in the "Add Block" list.
I want to remove the element with the value where $bt->getBlockTypeName() is "HTML" from the $blockTypes array.
Is that possible ?
So far I have been trying doing this by using this function:
unset($blockTypes["1"]);
But this function removes elements by array index. This is a problem because if I add a new addon, this function might remove the wrong addon.
Solution:
A filter. :)
foreach($bt as $key => $value) { if ($value == 'Content' || $value == 'HTML') {