Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add template hook for plugin devs #1

Open
erikreagan opened this issue Apr 17, 2015 · 0 comments
Open

Add template hook for plugin devs #1

erikreagan opened this issue Apr 17, 2015 · 0 comments

Comments

@erikreagan
Copy link
Member

Consider adding in a template hook for 3rd party devs to inject their own fieldtype sample code into the template.

http://buildwithcraft.com/classreference/services/TemplatesService#hook-detail

{% hook 'cheatSheetTemplate' %}
{% if fieldInfo is defined %}
    {% for pluginField in fieldInfo %}
        {{ csMacro.codeBlock(pluginField.title, pluginField.code, pluginField.helpText) }}
    {% endfor %}
{% else %}
    {# final no results html block #}
{% endif %}

Then plugin devs could use the init() method to modify the template context like so:

craft()->templates->hook('cheatSheetTemplate', function(&$context)
{
    $context['fieldInfo'] = array();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant