Developers

Did you create a block that's using stacks ?

Here you can find info on how to let your block integrate with the 'Used By' function.

 

How 'Used By' works:

Any stack that is used on a concrete5 website is used by a block. If you add a stack to a site, a 'Stack Display' Block will be created witch will hold the stack.

It is known how 'Stack Display' stores this stack-ID, so it can be retrieved and listed with 'Used By'.

 

'Used By' will itterate through all the blocks on a site and check if it holds the particular stack we try to find (if it holds any stacks at all).

 

But this doesn't work with custom blocks.

Other blocktypes that use stacks will also store the stack-ID's, but all in their own way (different variable names, different database fields, etc.). So I created a universal way to get this working for blocktypes that I don't know how they store things: adding a function to the block controller that returns the list of stacks that it's using.

 

Adding GetStacksUsed() to your controller

Add this public function to your block's Controller. It should return an array of stack-id's (strings) used by your block.

Here's an example:

 
// getStacksUsed, added to the block controller function (controller.php)
// return an array of SID's ($stack->getCollectionID())
// eg. $this->stacks = '13,15,131' will return array('13', '15', '131')
public function getStacksUsed() {
    $stacks = explode(',', $this->stacks); // change for your add-on !!
    return $stacks;
}

 

Feel free to contact me when you need some help with this.