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

Call a class inside a plugin

Started by Muut Archive 10 years ago · 2 replies · 450 views
10 years ago

Hello.
I'm pretty new on plugin development.
I have a calendar class I'd like to include on a grav web site.

I was successful following this tutorial:
https://learn.getgrav.org/cookbook/plugin-recipes#output-some-php-code-result-in-a-twig-template
but I've no idea how to use my custom class inside the ExampleTwigExtension class.
When I try to initialize my class ($c = new MyCal()) inside the TwigExtension, Grav says there is no such class, even if I require_once my external file.
Of course I'm doing something wrong but I have no clue.

10 years ago

I have a couple of plugins that use custom classes. iplocate jumps to mind. Take a look at iplocate.php to see how it works.

10 years ago

Thank you perlkonig! Thank you very much!

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1360 9 years ago
Archive · by Muut Archive, 9 years ago
2 939 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2958 9 years ago
Archive · by Muut Archive, 9 years ago
3 1122 9 years ago