Using a block $variable in the controller.

I am building a roster block for our local football team.

I am very new to this, but some forum searchin got me pretty far.

I got everying displayed like I want it now...

But my problem is that I want to make the block a little more 'dynamic'.

I want to be able select which user group to display as a roster when I add the block.


This is what I use now, and it works like a charm.

My add.php
<p>Enter the name on the usergroup that you want to display as a roster.</p>
<?php echo $form->label('teamNavn', 'Team Name');?>
<?php echo $form->text('teamName', array('style' => 'width: 320px'));?>

So in my view.php I can just: echo $teamName;

So far so good, but I cant do like this in my controller.php

So my question is: Is there any way that I can get the name I enter in add.php and use it in my controller.php?

To give you a better understanding i will include my controller.php as well.
    class BrewersRosterBlockController extends BlockController {
    var $pobj;
    protected $btDescription = "A Simple roster.";
    protected $btName = "Brewers Roster";
    protected $btTable = 'btBrewersRoster';
    protected $btInterfaceWidth = "350";
    protected $btInterfaceHeight = "300";
    public function view() {
        $userList = new UserList();
        $userList->sortBy('uName', 'asc');
        $userList->filterByGroup('Senior');  // This i want to change
        $users = $userList->getPage();
        $this->set('userList', $userList);

I hope you undersand what i am trying to do.

Thanks for your time.
Have a nice day

View Replies: View Best Answer
ScottC replied on at Permalink Best Answer Reply
inside a block assuming your field is teamName(which it appears to be, if your able to add and edit the block, then you would simply do $this->teamName inside your view function, each row in the db is set to a variable for the object.

*edit* Each field or column or in the case of getRow element of the array is mapped to the controller as a variable to the object.

so $this->teamName where you do filter by group will work.
qqa replied on at Permalink Reply
This works perfectly.

You described it in a way that makes sense.

You saved my day.


Have a nice day