kinglozzer/silverstripe-columnedlist

An SS_ListDecorator to facilitate stacking data vertically in columns

Installs: 1 931

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 3

Forks: 1

Open Issues: 0

Type:silverstripe-vendormodule

2.1.0 2024-05-30 09:57 UTC

This package is auto-updated.

Last update: 2024-11-30 11:06:06 UTC


README

Build Status Latest Stable Version Total Downloads License

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

Example:

use Kinglozzer\SilverStripeColumnedList\ColumnedList;
use SilverStripe\CMS\Model\SiteTree;

class Page extends SiteTree
{
    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:

“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: