This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

leocavalcante
leocavalcante

This isn't imposible today, but it is really tricky.

The idea is to enable the possibility to extend a ListController view, displaying another components beyond the list.

Look Example

To archive this top scoreboard and this top table I needed the records, its just some sums, avgs and business rules calculations.

The records are fetched when the Lists widget is rendered, so usually, the records are only available after the main table on the screen.

The trick was to render on the controller method and then pass to $vars.

$this->asExtension('ListController')->index();
$this->vars['renderedList'] = $this->listRender();

And then I could access records from the Lists widget $vars and pass it to my custom widgets.

/** @var LengthAwarePaginator $records */
$records = $this->widget->list->vars['records'];

Should not be better to pass the records to Lists widgets instead on letting it fetch them? So $records would be a Controller property that can pass it to whatever widgets is bind to it.

jvanremoortere
jvanremoortere

This is exactly what I'm trying to do. Trying to access the list variables in my scoreboard... Isn't there any better way to do this?

leocavalcante
leocavalcante

They just merged my PR to make this possible using OctobersCMS builtin extendability features! \o/ https://github.com/octobercms/october/pull/1853

You can just declare

public function listExtendRecords($records, $definition)
{
    // do something with $records
    return $records;
}
jvanremoortere
jvanremoortere

@leocavalcante you have a working example of this? Can't seem to get it to work ^o)

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.