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

PHP Plugin Question(s)

plugins

Started by Matt 8 years ago · 2 replies · 599 views
8 years ago

I am admittedly over my head, but I really would like to start using, and learning how to use, Grav more. I've been using Joomla from back in the Mambo days (before the split), but I'm having trouble grasping some parts of Grav, notably plugins.

What I'm trying to do is integrate a job posting script from PHPJabbers, and I can't quite grasp the plugin process.

This is what I need to do (screen shot below)...

URL to web page where jobs listing is placed (define)

Step 1. Copy and paste following code at very top of your page, before any other code.

<?php ob_start(); ?>

Step 2. Copy and paste following code inside your html code, where the job listing will be displayed.

{JL_LOAD}

Step 2a (Optional). Copy and paste the code below inside the part of your page, where the meta tags will be printed.

{JL_META}

Step 3. Copy and paste following code at very bottom of your page, after all the code.

<?php include '/home/pjabbers/public_html/153XXXXXXX_713/app/views/pjLayouts/pjActionLoad.php'; ?>

I've looked through the plugin recipes, downloaded sample plugins to get the concept, and read the docs... and I'm still lost.

Any nudges in the correct direction for a total n00b would be much appreciated.

Script integration screen shot...
Screen%20Shot%20on%202018-08-16%20at%2013_47_36|657x500

last edited 08/16/18 by Matt
8 years ago

The most important part of plugin coding that people seem to consistently miss is the Grav Lifecycle. That's how you know what events are available and which you need to target.

The problem here is that this service requires modifying PHP, not HTML. To my knowledge (and I'm not an expert), there's no way to do this using plugins. By the time plugins are called, Grav is already in complete control. The plugin can inject stuff in the final HTML, but it can't retroactively change the Grav PHP code.

What you can do is write a plugin that fetches the job data from an external API and then populate that into your HTML in any number of ways. (See the IPLocate plugin for an example.)

But Grav is essentially a super-powered templating system designed to generate HTML, not PHP. It runs on PHP itself, but it doesn't generate it.

8 years ago

Thanks for the reply. I really appreciate it! I think I'll need to explore other options.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
3 96 5 hours ago
Support · by Anna, 3 days ago
2 95 1 day ago
Support · by Justin Young, 1 day ago
1 64 1 day ago
Support · by Duc , 1 week ago
2 100 6 days ago
Support · by Colin Hume, 1 week ago
2 92 6 days ago