<p>I found a solution for this one, actually, you can do this with:</p>

<p><strong>Javascript</strong>: <code>Craft.elementIndex.addButton($('&lt;a href="http:/##" class="btn submit" /&gt;').html('test'))</code></p>

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

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

<p>Done.
I hope this helps others too.</p>

CC BY-SA 3.0
2015-03-25T18:48:40.293Z
2015-03-25T19:09:47.273Z
2015-03-25T19:09:47.273Z
Marlon Marcello
<p>I can't find a way to include buttons on the correct place at the sidebar of my plugin.</p>

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

<p><img src="https://i.sstatic.net/p4vcp.png" alt="enter image description here"></p>

<p>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?</p>

<p>I couldn't find on the templates the correct place.</p>

<p>[EDIT]</p>

<p>Here's my template.</p>

<pre><code>{% extends "_layouts/elementindex" %}
{% includeCssResource "crashC/css/crashC.css" %}

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

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

<p>Thanks a lot for the help!</p>

<templating>
How can I add buttons to the sidebar?
# How can I add buttons to the sidebar?

(Asked by: username_0 on 2015-03-25)

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:

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.
[EDIT]
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 %}
  Download CSV
  {{ parent() }}
{% endblock %}

Thanks a lot for the help!

**Tags:** templating

---

## 1 answers

### Answer by username_0 on 2015-03-25. Score: 2

I found a solution for this one, actually, you can do this with:
Javascript: Craft.elementIndex.addButton($('').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 %}
  
     Download CSV
  
  {{ parent() }}
{% endblock %}

Done.
I hope this helps others too.


---

