About Events Fieldtype

Field that stores a table of events for a page. This modules serves as an example of creating an editable table of data as a Fieldtype and Inputfield in ProcessWire.

Category 1Field Types
Fieldtype modules that represent a data type used by fields.
Category 2Input Fields
Inputfield modules that provide a UI input widget in the ProcessWire admin.
Category 3Proof of Concept
Proof of concept modules are designed as examples or starting points for others to build from. May not be ideal for users wanting to plug-n-play.
Release StateStable
Should be safe for use in production environments. *
Authorryan
Module Version0.0.3
Class NameFieldtypeEvents
Compatibility2.3, 2.4, 2.5, 2.6, 2.7
Date AddedNovember 27, 2013
Recommended ByNew recommendations may take up to 1 day to appear.

Instructions

This module's files should be placed in /site/modules/FieldtypeEvents/
How to install or uninstall modules

README

FieldtypeEvents

This modules serves as an example of creating an editable table ofdata as a Fieldtype and Inputfield in ProcessWire. In this case, we create a simple table of events each with date, location and notes. This pattern can be adapted to nearly any table of information.

Note that this module is intended as a proof-of-concept. If youfind it useful for the example scenario (events) then great, but keep in mind it is not intended as a comprehensive events solution, where using ProcessWire pages may be a better fit.

screenshot.png

Install

  1. Copy the files for this module to /site/modules/FieldtypeEvents/
  2. In admin: Modules > Check for new modules. Install Fieldtype > Events.
  3. Create a new field of type Events, and name it whatever you wouldlike. In our examples we named it simply "events".
  4. Add the field to a template and edit a page using that template.

Output

A typical output case for this module would work like this:

foreach($page->events as $event) {
  echo "
    <p>
    Date: $event->date<br />
    Location: $event->location<br />
    Notes: $event->notes
    </p>
    ";
}

This module provides a default rendering capability as well, so thatyou can also do this (below) and get about the same result as above:

echo $page->events; 

...or this:

foreach($page->events as $event) {
  echo $event;
}

Finding events

This fieldtype includes an indexed date field so that you can locateevents by date or within a date range.

// find all pages that have expired events
$results = $pages->find("events.date<" . time());

// find all pages with events in January, 2014
$results = $pages->find("events.date>=2014-01-01, events.date<2014-02-01");

Comments

No comments yet. Be the first to post!

Post a Comment

Your e-mail is kept confidential and not included with your comment. Website is optional.