You are here

README.txt in Grid Field Formatter 7

As an attempt to provide a solution to:
How do I format a multi value field as a grid? [http://drupal.org/node/1826330]
the Grid Field Formatter module provides a simple way to overridde the display
of multi-value fields to show as a grid/table with a certain number of columns.

This module has no pretention of implementing any field: it is not a Table
field, such as TableField (http://drupal.org/project/tablefield), or CCK Table
Field (<a href="http://drupal.org/project/cck_table)
It's just a formatter (display) to render multi-value fields with a grid/table
layout instead of a list of items.

The idea behind this is to provide a simple solution, easy to use, setup, with
few dependencies and trying to leverage the formatter hooks provided by
#945524: Field formatter settings hooks in core (http://drupal.org/node/945524)
to extend existing field formatters.


1 - Implementation:

The code is very similar to other modules built on top of Field formatter
settings (http://drupal.org/project/field_formatter_settings), such as Linked
field (http://drupal.org/project/linked_field) or Field formatter class
(http://drupal.org/project/field_formatter_class), and it implements
"hook_field_formatter_settings_form_alter" to add configuration options to
existing formatter settings forms. Module provides its own template file and
also introduces template suggestions to allow overridding in specific cases:
- grid-field-formatter.tpl.php
- grid-field-formatter--[FIELD_TYPE].tpl.php
- grid-field-formatter--[FIELD_NAME].tpl.php
- grid-field-formatter--[FIELD_NAME]--[BUNDLE].tpl.php

It seems this function could also be achieved by using Custom Formatters
(http://drupal.org/project/custom_formatters, See module's tracker page for
more information, or overriding Field theme files and functions, or even with
Views (http://drupal.org/project/views) and fields related modules (for example
View reference - http://drupal.org/project/viewreference).
Another solution would be to use the Mansory(http://drupal.org/project/masonry)
module which seems to allow display of multi-value fields in a Masonry grid
layout, using Javascript.
But since this is a recurring request with such a simple and light
implementation, it could be considered as a standalone module.


2 - Integration:

This module plays well and has been tested with:
Image (http://drupal.org/documentation/modules/image), Lightbox2
(http://drupal.org/documentation/modules/lightbox2), Entity reference
(http://drupal.org/project/entityreference) and Drupal Commerce Product
Reference (http://drupal.org/project/commerce).

A pretty cool and simple setup or application of this module would be, for
example, to build a simple image gallery, with thumbnails, opening in a
lightbox and displayed in a grid/table layout with 5 columns:
Add a Content Type Photo Album, for example, with a multi-value Image field.
Make sure Grid Field Formatter is enabled for the Image field type. Then,
configure the display formatter of the image field in the Photo Album to
display in a lightbox (http://drupal.org/project/lightbox2), with its multi
value thumbnails in a grid layout with 5 columns.

Another example would be to display in a table layout with 4 columns, 'Related
Products" provided by a multi-value Product Reference or Entity Reference
field. By enabling grid field formatter for these fields for the given view
mode, the values (for example, products with an add to cart form) would display
in a table/grid layout.

This module was also tested and has no conflict with Fences
(http://drupal.org/project/fences), and other similar modules for content
display or theme utilities related with the markup of fields.


3 - Installation and configuration:

a. Prerequisite: 
Requires Field formatter settings to be installed.
(http://drupal.org/project/field_formatter_settings)

b. Download the module and simply copy it into your contributed modules folder:
[for example, your_drupal_path/sites/all/modules] and enable it from the
modules administration/management page.
More information at: Installing contributed modules (Drupal 7)
[http://drupal.org/documentation/install/modules-themes/modules-7]

b. Configuration:
- After successful installation, browse to the "Grid Field Formatter" settings
page (under Configuration > Content), and select the field types for which the
Grid Field Formatter should be made available.

- Then, browse to the "Manage Display" settings page, for an entity (Node
content type, for example) with one of the field of the type that was selected
in 2.a, to configure the formatter (See attached screenshots).
For example: the page content type:
Home » Administration » Structure » Content types » Page » Manage display

In the field formatter settings form, enable Grid Field Formatter and provide
the number of columns (don't forget to save the form).



4 - Contributions are welcome!!

Feel free to follow up in the issue queue for any contributions, bug reports,
feature requests.
Tests, feedback or comments in general are highly appreciated.

5 - Credits:

This module was sponsored by DAVYIN Internet Solutions [http://www.davyin.com].

File

README.txt
View source
  1. As an attempt to provide a solution to:
  2. How do I format a multi value field as a grid? [http://drupal.org/node/1826330]
  3. the Grid Field Formatter module provides a simple way to overridde the display
  4. of multi-value fields to show as a grid/table with a certain number of columns.
  5. This module has no pretention of implementing any field: it is not a Table
  6. field, such as TableField (http://drupal.org/project/tablefield), or CCK Table
  7. Field (
  8. existing formatter settings forms. Module provides its own template file and
  9. also introduces template suggestions to allow overridding in specific cases:
  10. - grid-field-formatter.tpl.php
  11. - grid-field-formatter--[FIELD_TYPE].tpl.php
  12. - grid-field-formatter--[FIELD_NAME].tpl.php
  13. - grid-field-formatter--[FIELD_NAME]--[BUNDLE].tpl.php
  14. It seems this function could also be achieved by using Custom Formatters
  15. (http://drupal.org/project/custom_formatters, See module's tracker page for
  16. more information, or overriding Field theme files and functions, or even with
  17. Views (http://drupal.org/project/views) and fields related modules (for example
  18. View reference - http://drupal.org/project/viewreference).
  19. Another solution would be to use the Mansory(http://drupal.org/project/masonry)
  20. module which seems to allow display of multi-value fields in a Masonry grid
  21. layout, using Javascript.
  22. But since this is a recurring request with such a simple and light
  23. implementation, it could be considered as a standalone module.
  24. 2 - Integration:
  25. This module plays well and has been tested with:
  26. Image (http://drupal.org/documentation/modules/image), Lightbox2
  27. (http://drupal.org/documentation/modules/lightbox2), Entity reference
  28. (http://drupal.org/project/entityreference) and Drupal Commerce Product
  29. Reference (http://drupal.org/project/commerce).
  30. A pretty cool and simple setup or application of this module would be, for
  31. example, to build a simple image gallery, with thumbnails, opening in a
  32. lightbox and displayed in a grid/table layout with 5 columns:
  33. Add a Content Type Photo Album, for example, with a multi-value Image field.
  34. Make sure Grid Field Formatter is enabled for the Image field type. Then,
  35. configure the display formatter of the image field in the Photo Album to
  36. display in a lightbox (http://drupal.org/project/lightbox2), with its multi
  37. value thumbnails in a grid layout with 5 columns.
  38. Another example would be to display in a table layout with 4 columns, 'Related
  39. Products" provided by a multi-value Product Reference or Entity Reference
  40. field. By enabling grid field formatter for these fields for the given view
  41. mode, the values (for example, products with an add to cart form) would display
  42. in a table/grid layout.
  43. This module was also tested and has no conflict with Fences
  44. (http://drupal.org/project/fences), and other similar modules for content
  45. display or theme utilities related with the markup of fields.
  46. 3 - Installation and configuration:
  47. a. Prerequisite:
  48. Requires Field formatter settings to be installed.
  49. (http://drupal.org/project/field_formatter_settings)
  50. b. Download the module and simply copy it into your contributed modules folder:
  51. [for example, your_drupal_path/sites/all/modules] and enable it from the
  52. modules administration/management page.
  53. More information at: Installing contributed modules (Drupal 7)
  54. [http://drupal.org/documentation/install/modules-themes/modules-7]
  55. b. Configuration:
  56. - After successful installation, browse to the "Grid Field Formatter" settings
  57. page (under Configuration > Content), and select the field types for which the
  58. Grid Field Formatter should be made available.
  59. - Then, browse to the "Manage Display" settings page, for an entity (Node
  60. content type, for example) with one of the field of the type that was selected
  61. in 2.a, to configure the formatter (See attached screenshots).
  62. For example: the page content type:
  63. Home » Administration » Structure » Content types » Page » Manage display
  64. In the field formatter settings form, enable Grid Field Formatter and provide
  65. the number of columns (don't forget to save the form).
  66. 4 - Contributions are welcome!!
  67. Feel free to follow up in the issue queue for any contributions, bug reports,
  68. feature requests.
  69. Tests, feedback or comments in general are highly appreciated.
  70. 5 - Credits:
  71. This module was sponsored by DAVYIN Internet Solutions [http://www.davyin.com].