kinglozzer/silverstripe-columnedlist

An SS_ListDecorator to facilitate stacking data vertically in columns

Installs: 237

Dependents: 0

Suggesters: 0

Stars: 6

Watchers: 2

Forks: 1

Open Issues: 0

Type: silverstripe-module

1.0.1 2015-01-12 15:10 UTC

README

Build Status

An SS_ListDecorator to facilitate stacking data vertically in columns. Supports left and right “weighting”.

Example:

class Page_Controller extends Controller {

    public function ColumnData() {
        return ColumnedList::create($this->SomeDataList());
    }

}
<% loop ColumnData.Stacked(3) %>
    <div style="float: left">
        <h3>Column {$Pos}</h3>
        <ul>
            <% loop Children %>
                <li>Item {$Pos}</li>
            <% end_loop %>
        </ul>
    </div>
<% end_loop %>

Assuming SomeDataList() contains 5 items, the output would be:

Column 1 Column 2 Column 3
Item 1 Item 3 Item 5
Item 2 Item 4

“Right-heavy” stacking:

Using the same above example:

<% loop ColumnData.Stacked(3, 'Children', 0) %>
    <div style="float: left">
        <h3>Column {$Pos}</h3>
        <ul>
            <% loop Children %>
                <li>Item {$Pos}</li>
            <% end_loop %>
        </ul>
    </div>
<% end_loop %>

Assuming SomeDataList() contains 5 items, the output would be:

Column 1 Column 2 Column 3
Item 1 Item 2 Item 4
Item 3 Item 5