This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

If you have a block and you run

$this->getIdentifier();

you will end up with the same block id for the original block and that block in the clipboard.

Instead you can do this

$this->set(
  'blockIdentifier',
  $this->getBlockObject()->getProxyBlock()
    ? $this->getBlockObject()->getProxyBlock()->getInstance()->getIdentifier()
    : $this->getIdentifier()
);

Then in your view.php you can do

<div id="<?php echo $blockIdentifier ?>"></div>

and trust that all the blocks on your page will have unique ids, even if pasted from the clipboard.

Update: Shahroq has wisely informed me that this code only works in concrete5.6.0 and above. In versions below that it will throw an error as the the method Block::getProxyBlock() did not yet exist.

Loading Conversation