Skip to main content

Using OnePlugin Fields

OnePlugin Fields supports nine different media types, adding them to your Craft project and configuring them to your site is super simple.

OnePlugin Fields adds a custom FieldType to Craft CMS, called OnePlugin Fields. This functions in the same way as a PlainText or Asset field, but you can configure this field to render nine different content types, including

One of our favourite usecases for OnePlugin Fields has to be truely customisable blog templates. This gives content managers the ability to switch between between different types of media. More importantly, it allows for content to be generated from within the control panel. All while optimising the media type so it's served as efficiently as possible.

OnePlugin Fields works standalone and inside matrix blocks.

Adding OnePlugin Fields#

It's very simple to add OnePlugin Fields to your page. There are two ways to do this.

Option #1

Add OnePlugin Fields as a standalone field.

Docusaurus

Option #2

Add OnePlugin Fields to a matrix block.

Docusaurus

Field media type content configuration#

Configure what media types are allowed to your OnePlugin Fields from your field settings. Restrict the template sections utilising OnePlugin fields to specific content types. Why you ask? In order to provide flexible content that works with your sites design guidelines and container styles.

The following options are available:

  • All
  • Allow Images
  • Allow Videos
  • Allow Social Media Content
  • Allow Websites
  • Allow Google Maps
  • Allow Animated Icons
  • Allow SVG Icons
  • Allow PDF Documents
  • Allow Office Documents

Configure each block individually in order to provide users guidelines and bring value to your clients site.

Rendering OnePlugin Fields#

Rendering OnePlugin Fields is simple, check out features for media specific code examples.

{{ ctaAsset.render() }}

OnePlugin Fields require jQuery and some other Javascript libraries to render contents types like Animated Icons, PDF, Google Maps etc.

Configuring your twig files#

Add the below code snippet to your Twig file preferably in the Footer.

{{ craft.onePluginFields.includeAssets(true,true,true) }}
  • includejQuery - Will include jQuery library. Default is false
  • includePDF - Will include PDF library required to render PDF files. Set this to true only if PDF's are used in the page. Default is false
  • includeMap - Will include Google Maps library required to render Maps. Set this to true only if Maps are used in the page. Default is false

Example#

These examples show how the same field is rendered using different media types.

Image

Docusaurus

Video

Docusaurus

Website

Docusaurus

Animated Icon

Docusaurus

SVG

Docusaurus

PDF

Docusaurus

Office Document

Docusaurus