Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

How to add a modular plugin to a page

Started by Muut Archive 11 years ago · 2 replies · 337 views
11 years ago

I've got a modular page, and the simple_contact plugin installed. I've followed the installation instructions to the letter, but can't wrap my head around how to display the actual form on a modular page.

Plugin documentation says it's supposed to function as a module on a modular page. HOW to accomplish this is not answered.

This is really a more general question: How does one display a module from a plugin? Seems reasonable that you should jack them up the same way.

There is a template for displaying the plugin: page/user/plugins/simple_contact/templates/plugins/simple_contact/form .html.twig

There's a modular page in page/user/pages called "01.home". In this folder, there's a file modular.md.

That file looks like this:

YAML
title: Ttile
menu: Home
simple_contact: true
content:
    items: @self.modular
    order:
        by: default
        dir: asc
        custom: 
            - _top
            - _quote
            - _highlights
            - _twocol
            - _textblock

The other sections display fine, and in the correct order (All the corresponding folders and .md files are in place). The form does not display at all.

I've tried adding a module content folder "_simple_contact" (and a simple_contact.md inside) to the page, in the hopes that grav would get that it should fetch the template from the plugin. That didn't work. Instead it throws an exception, looking for "modular/simple_contact.html.twig". So it doesn't get that it should use the plug.

I've tried creating the template Grav asks for, and calling the plugin from there. But that quickly turned really awkward, because there is no documentation on how to render a plugin template. At worst, it throws an error. At best, it displays an empty section (only some arbitrary div wrappers and such, but no content, and absolutely no form.)

My question, I guess, is "How does one display a module from a plug on a modular page?", because I can't really seem to do that.

11 years ago

I'm assuming that the simplecontact plugin registered the user/plugins/simplecontact/templates folder with Twig. That being so if you wanted to explicitly include the template from any other twig template you would use the following:

TWIG
{% include 'plugins/simple_contact/form.html.twig' %}

Is that what your asking?

11 years ago

That does the trick. Thanks a lot!

I did a lot of convoluted stuff because I assumed I could somehow do this from markdown.

It was a lot simpler this way, though.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1336 9 years ago
Archive · by Muut Archive, 9 years ago
2 925 9 years ago
Archive · by Muut Archive, 9 years ago
2 4056 9 years ago
Archive · by Muut Archive, 9 years ago
1 2941 9 years ago
Archive · by Muut Archive, 9 years ago
3 1112 9 years ago