gorriecoe/silverstripe-action

Adds basic call to action DataObject.

Installs: 113

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Type:silverstripe-vendormodule

dev-master 2018-07-15 22:25 UTC

This package is auto-updated.

Last update: 2024-03-29 03:26:07 UTC


README

Adds basic call to action DataObject.

Installation

Composer is the recommended way of installing SilverStripe modules.

composer require gorriecoe/silverstripe-action

Requirements

  • silverstripe/cms ^4.0
  • gorriecoe/silverstripe-link ^1.0
  • gorriecoe/silverstripe-preview ^1.0

Maintainers

Usage

use gorriecoe\Action\Models\Action;
...

class Page extends SiteTree
{
    private static $many_many = [
        'Actions' => Action::class
    ];

    private static $many_many_extraFields = [
        'Actions' => [
            'Sort' => 'Int'
        ]
    ];

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->addFieldsToTab(
            'Root.Main',
            [
                GridField::create(
                    'Actions',
                    'Actions',
                    $this->Actions(),
                    GridFieldConfig_RecordEditor::create()
                        ->addComponent(new GridFieldOrderableRows('Sort'))
                )
            ]
        );
    }
}
<% loop Actions.sort('Sort ASC') %>
    <% with Preview %>
        <div class="call-to-action">
            {$Image.Fill(300,200)}
            <h2>
                {$Title}
            </h2>
            <p>
                {$Summary.Summary}
            </p>
            <a href="{$LinkURL}">
                {$Label}
            </a>
        </div>
    <% end_with %>
<% end_loop %>