CakePHP
  • Documentation
    • Bootstrap UI
    • CakePDF
    • Crud
    • Crud Users
    • Crud View
    • CsvView
    • Search
  • Community
    • Help & Support
    • Stack Overflow
    • IRC
    • Slack
CakePHP

B Crud View Documentation

Page Contents

  • Index as a Gallery
    • Customizing the Gallery fields
    • Customizing Gallery Field Output
    • Default Image
    • Available Variables

Index as a Gallery¶

Render your index page as a gallery.

$action = $this->Crud->action();
$action->setConfig('scaffold.index_type', 'gallery');

Customizing the Gallery fields¶

The gallery index type has several options:

  • scaffold.index_title_field: (default: displayField for current table) Controls the field used for each gallery entry title.

  • scaffold.index_image_field: (default: image) Controls the field used for each gallery entry image.

  • scaffold.index_body_field: (default: body) Controls the field used for each gallery entry body.

  • scaffold.index_gallery_css_classes: (default: col-sm-6 col-md-3) Controls the css classes applied to each gallery entry, useful for specifying how many entries should go on a single page.

$action = $this->Crud->action();
$action->setConfig('scaffold.index_title_field', 'name');
$action->setConfig('scaffold.index_image_field', 'image');
$action->setConfig('scaffold.index_body_field', 'content');
$action->setConfig('scaffold.index_gallery_css_classes', 'col-sm-4 col-md-2');

Customizing Gallery Field Output¶

For each field, we will also retrieve configuration from the scaffold.fields configuration key for formatting each field:

$action = $this->Crud->action();
$action->setConfig('scaffold.fields', [
    'image' => [
        'width' => '240',
        'height' => '240'
    ],
]);

Default Image¶

If no image is retrieved, CrudView will default to the following transparent gif:

data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==

Available Variables¶

The following variables are available for use within the element:

  • indexImageField: The field containing the gallery entry image

  • indexTitleField: The field containing the gallery entry title

  • indexBodyField: The field containing the gallery entry body

  • fields: List of fields to show and their options

  • actions: A list of actions that can be displayed for the index page.

  • bulkActions: A list of bulk actions associated with this resource

  • primaryKey: The name of the record’s primary key field.

  • singularVar: The singular version of the resource name.

  • viewVar: Reference to the name of the variable holding all records.

  • plural of viewVar: The set of records.

Preface

  • Installation
  • Quick Start

Usage

  • Basic Usage
  • Customizing Templates

General Configuration

  • Breadcrumbs
  • Site Title Options
  • Sidebar Navigation
  • Utility Navigation

Dashboard Pages

  • Customizing the Dashboard

Index Pages

  • Customizing the Index Page
  • Custom Index
  • Index as a Blog
  • Index as a Gallery
  • Index as a Table

Form Pages

  • Customizing the Form

Navigation

  • index
  • next |
  • previous |
  • Crud View »
  • Index as a Gallery
  • Documentation
  • Bootstrap UI
  • CakePDF
  • Crud
  • Crud Users
  • Crud View
  • CsvView
  • Search
  • Help & Support
  • Stack Overflow
  • IRC
  • Slack

© Copyright 2026, Friends of Cake. Last updated on May 23, 2026. Created using Sphinx 7.4.7.