I can't find a way to include buttons on the correct place at the sidebar of my plugin.

So I noticed that on the sidebar markup, there's a div for buttons, there's created automatically:

enter image description here

I can easily add anything to the sidebar, I can include the buttons on the top, as you can see on the example, but my question is, how do I add the buttons to that div?

I couldn't find on the templates the correct place.


Here's my template.

{% extends "_layouts/elementindex" %}
{% includeCssResource "crashC/css/crashC.css" %}

{% set title = "Entries" %}
{% set selectedTab = 'entries' %}
{% set elementType = "CrashC" %}
{% set docsUrl = '' %}

{% block sidebar %}
  <a href="http://##" class="btn submit">Download CSV</a>
  {{ parent() }}
{% endblock %}

Thanks a lot for the help!


I found a solution for this one, actually, you can do this with:

Javascript: Craft.elementIndex.addButton($('<a href="http:/##" class="btn submit" />').html('test'))

Template: Just add a div with class .buttons, Craft's javascript will check for that and you won't get duplicated divs.

{% block sidebar %}
  <div class="buttons">
     <a href="http://##" class="btn submit">Download CSV</a>
  {{ parent() }}
{% endblock %}

Done. I hope this helps others too.

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.