How to adapt this code to 5.7?

Permalink
Hi,

Trying to use the code here to give my blocks instances a unique identifier:http://www.concrete5.org/documentation/how-tos/developers/obtain-a-...

I get an error "Call to undefined method Concrete\Core\Block\View\BlockView::set()"
How can I adapt this code to 5.7?

Thanks
Dave

madesimplemedia
 
madesimplemedia replied on at Permalink Best Answer Reply
madesimplemedia
Got this sussed, ended up using the block ID:

<?php
$bID = intval($bID);
?>

<a href="#" class="anchor<?php echo $bID ?>"></a>
JohntheFish replied on at Permalink Reply
JohntheFish
bID will run into non-unique problems with copied blocks, blocks in stacks that are used in multiple places, and page types. As long as you stay away from any of these edge cases, you will be OK. The howto avoided all edge cases by ensuring a repeatedly unique id, but was written with 5.6 in mind.
JohntheFish replied on at Permalink Reply
JohntheFish
Looking at your error report above, I suspect it was because you were running the howto code in a view. It needs to be run in a block controller. Maybe it will actually still work in 5.7?
madesimplemedia replied on at Permalink Reply
madesimplemedia
Hi
You're right about adding it to view, I'll add to the controller and see if it works.
Thanks
Dave