$block->getBlockID()
Permalink
is there a way to show the block id when i am in edit mode. I can see $block->getBlockID() Returns the ID of the block but not sure how to code this. I guess the code is placed in the edit.php of the block.
Well the simple way is to just use $bID. This is possible because on the load for the block, all the database fields are created by the same name. So for that block if the other database fields are answer, question... You could use $answer and $question to get these values. Which if you do not like this for readability, I have also seen the use of $this->bID and $controller->bID. All ways are correct.
The view.php of every block has access to the $bID variable which is automatically set.
A simple example to show the $bID in edit mode:
There are other ways to access/display the block ID, but it depends on what specifically you are trying to accomplish.
A simple example to show the $bID in edit mode:
$c = Page::getCurrentPage(); if(!$c->isEditMode()){ // Not in edit mode }else{ // In edit mode echo $bID; }
There are other ways to access/display the block ID, but it depends on what specifically you are trying to accomplish.
@beebs93, many thanks works perfectly.