Coder Social home page Coder Social logo

fieldtypeevents's Introduction

FieldtypeEvents (and InputfieldEvents)

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

Note that this module is intended as a proof-of-concept. If you find 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. If you use this Fieldtype then chances are you'll want to use it as a starting point for further development rather than as a final solution.

Upgrade

If you are using a previous version of this module, please note that this one is different and simplified from the previous version. As a result, if you are actually using the module for real (rather than an example or demo) then you shouldn't upgrade.

Install

  1. Copy the files for this module to /site/modules/FieldtypeEvents/
  2. In admin: Modules > Refresh. Install Fieldtype > Events.
  3. Create a new field of type Events, and name it whatever you would like. 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 />
      Title: $event->title
    </p>
    ";
}

Finding events

This fieldtype includes an indexed date field and fulltext indexed title field so that you can locate events by date or text.

// find all pages that have events after May 1, 2021
$results = $pages->find('events.date>2021-05-01');

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

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

// find all pages with events that have the word “convention” in the title
$results = $pages->find("events.title~=convention"); 

fieldtypeevents's People

Contributors

ryancramerdesign avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fieldtypeevents's Issues

Double entity encoding when rendering events in admin

@ryancramerdesign

Thanks for this module - it's serving as a really useful example for me at the moment. However, as reported here by Valery, the output does seem to get double entity encoded when displayed in the containing PW page.

I can only guess that the containing page (or fieldset) is entity encoding the string from Event.php#96.

Whilst forcing output formatting on (line 95) does cause the event's fields to be entity encoded, the entire output including html markup in line 96 seems to be encoded later leading to it not displaying as desired and with double encoding of values from the fields. For example...

fieldtypeevents

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.