Server-side helpers

Beyond reusing PHP classes, Elefant allows a developer to specify handlers in their apps as being "helpers" which can be reused in other apps.

To see a list of available helpers, visit the helpers reference, or run the following command:

$ ./elefant list-helpers

This will output a raw list of handler names. To see what a given handler does and how to use it, you can use the following command:

$ ./elefant helper-docs <helper>

This will output the documentation found in the first block-level comment in the handler script.

For example, if you run:

$ ./elefant helper-docs blog/tags

This will output:

# Helper: blog/tags

Renders a tag cloud, with more frequently used tags appearing larger.

This helper uses no parameters, so calling it is as simple as:

<?php

echo $this->run ('blog/tags');

And including it in your template is as simple as this:

{! blog/tags !}

The blog/rssviewer helper lists one parameter:

# Helper: blog/rssviewer

Renders the specified RSS feed `url` as a list of links.
Caches the feed for 30 minutes between updates.

Parameters:

- `url`: The URL of the RSS feed to be displayed.

So we know that to use this helper, we need to include the URL like this:

<?php

echo $this->run (
    'blog/rssviewer',
    array (
        'url' => 'http://www.example.com/blog/rss'
    )
);

And the same thing called from a template:

{! blog/rssviewer?url=http://www.example.com/blog/rss !}

For a full list of helpers and what they do, visit the helpers reference.

Next: Client-side helpers

Edit this page.
This documentation was generated by the Elefant Documentation Project. We're always open to new contributions *wink* *wink*