concrete5 how to access block parameter in controller

218 Views Asked by At

This might be a silly question but i'm new to concrete5 and i can't find any answer to this.

I have a custom block made in concrete5 (with view.php, db.xml, controller.php etc.) which takes a single parameter. Now how can i access that block's parameter in my controller ? I know it's easy in the view.php file, I just type something like echo $var, where var is the name of my parameter in the block database. But this doesn't work in the controller file. Any help ?

1

There are 1 best solutions below

0
On BEST ANSWER

They are set as the block controller's public properties with the same names.

So, e.g.

class YourBlockController extends BlockController {

    public function view() {
        // This would be named as "blockParameter" in your db.xml
        if ($this->blockParameter) {
            // This gets custom parameters bound to the view, so in view
            // you can now e.g. <?php echo $foo ?> <-- echoes "bar"
            $this->set('foo', 'bar');
        }
    }

}

The class naming in this answer is according to 5.6 and before. For 5.7 it's a bit different.