For arguments sake let's say I wanted a plugin that is a basic output:

<?php echo '<p>Hello World</p>'; ?>

So all I am wanting to output is that, and I want that output to be available via twig (ie: {{ helloworld }}

Not passing any information, not doing anything with the craft database, etc. Just very basic.


Have a look at plugin template variables. You can simply create a method in your plugins variable file that returns anything you want to the template, which would be accessible via {{ craft.myplugin.customVariable }}.

namespace Craft;

class MypluginVariable
    public function customVariable($someProperty = 'defaultValueIfNotDefined')
        return 'Whatever you want!';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.