Skip to content

jgonyea/grav-bibleref

develop
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Bibleref Plugin

The Bibleref Plugin is for Grav CMS. It adds fields to the header (and admin form) for Bible references by version, book, and chapter.

Installation

Installing the Bibleref plugin can be done in one of two ways. The GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.

GPM Installation (Preferred)

The simplest way to install this plugin is via the Grav Package Manager (GPM) through your system's terminal (also called the command line). From the root of your Grav install type:

bin/gpm install bibleref

This will install the Bibleref plugin into your /user/plugins directory within Grav. Its files can be found under /your/site/grav/user/plugins/bibleref.

Manual Installation

To install this plugin, just download the zip version of this repository and unzip it under /your/site/grav/user/plugins. Then, rename the folder to bibleref. You can find these files on GitHub or via GetGrav.org.

You should now have all the plugin files under

/your/site/grav/user/plugins/bibleref

NOTE: This plugin is a modular component for Grav which requires Grav and the Error and Problems to operate.

Configuration

Currently, there are no configuration options.

Usage

Adding a reference via Admin

Add the following code to your theme to add the fields to your page type 'TYPE' (e.g. 'default' or 'blog'):


    use Grav\Common\Data\Blueprints;
    use RocketTheme\Toolbox\Event\Event;

    .
    .
    .
    .

    public static function getSubscribedEvents()
    {
        return [
            'onBlueprintCreated' => ['onBlueprintCreated', 0]
        ];
    }

    /**
     * Extend page blueprints with bibleref fields.
     *
     * @param Event $event
     */
    public function onBlueprintCreated(Event $event)
    {
        $blueprint = $event['blueprint'];
        if (!$inEvent && $blueprint->getFilename() == 'TYPE') {
            $blueprints = new Blueprints('user/plugins/bibleref/blueprints/');
            $extends = $blueprints->get('bibleref');
            $blueprint->extend($extends, true);
        }
    }

Add Bible references via the fields and save your content. Admin Fields

Adding a reference via Markdown headmatter

Add a Bible references to the header similarly to below:

title: New Page Title
bible_references:
    -
        version: ESV
        book: Genesis
        chapter: '1'
    -
        version: KJV
        book: Matthew
        chapter: '1'
---

Displaying references

To display all references on a page in your theme, use the following in your theme's template:

{% include 'partials/bibleref.html.twig' %}

and the page will display a div with class "bible-references" containing URLs to BibleGateway.com with the selected references.

Credits

This project was inspired by Bible Field from Drupal found here.

Known Issues

  • Similar to the Drupal module, the maximum available chapter defaults to 150 instead of following the actual maximum per book.

To Do

  • Add a default version to the plugin, but allow override per page.
  • Add more available translation versions from BibleGateway.com.
  • Follow the per-book max chapter rather than defaulting to the overall maximum of 150.
  • Add verses to reference.
  • Allow multiple page types to have the reference added.

About

Provides a field for bible references

Resources

License

Stars

Watchers

Forks

Packages

No packages published