<p>Not sure if you can put it next to the Share button, but check out the <strong>Triggers</strong> feature of Button Box...</p>

<blockquote>
  <p><a href="https://github.com/supercool/buttonbox" rel="nofollow noreferrer">https://github.com/supercool/buttonbox</a></p>
</blockquote>

<p>You can create a "Triggers" field, which is just a button that hooks up to JS. Then use the JS to ping your Controller via AJAX.</p>

<p>The button exists as a <em>field</em>, so you could just put that field at the top of your field layout. It's not well documented, but it's really easy to do.</p>

CC BY-SA 4.0
2018-06-11T01:00:18.027Z
Thanks for the reply! I need this to be more tightly integrated via my plugin, though. It's a workflow thing. And I need to link to another CP screen, passing along the entry ID.
Mark J. Reeves
CC BY-SA 4.0
2018-06-11T00:40:55.213Z
2018-06-11T00:40:55.213Z
Lindsey D
<p>I learned in <a href="https://craftcms.stackexchange.com/questions/14516/how-to-add-a-custom-button-at-the-right-section-of-an-entry">this ticket</a> that you can do this with <code>Craft::$app-&gt;getView()-&gt;hook()</code> in your plugin's <code>init()</code> method.  It won't put the button in the top near the "Share" button but rather in the sidebar under the settings.  Here's an example (you'll want to customize it to your liking):</p>

<pre><code>Craft::$app-&gt;getView()-&gt;hook('cp.entries.edit.details', function(array &amp;$context) {

    $entry = $context['entry'];

    if ((int)$entry-&gt;sectionId === YOUR_SECTION_ID_HERE) {

        $url = '/your/controller/action/url/';

        return '&lt;div class="meta"&gt;&lt;a href="' . $url . '" class="btn"&gt;My Button&lt;/a&gt;&lt;/div&gt;';
    }

});
</code></pre>

CC BY-SA 4.0
2019-01-20T19:21:47.177Z
2019-01-20T19:21:47.177Z
Ryan
<p>I would like to add a button to the edit entry screen, only for already saved entries, alongside the "Share" button.</p>

<p>When clicked, I'd like to call my plugin's controller action and post the entry ID.</p>

<p>Where would I look to see how to do this?</p>

<plugin-development><plugins><control-panel><controller><editing>
Add a button to the entry edit screen via plugin
# Add a button to the entry edit screen via plugin

(Asked by: username_0 on 2018-06-11)

I would like to add a button to the edit entry screen, only for already saved entries, alongside the "Share" button.

When clicked, I'd like to call my plugin's controller action and post the entry ID.

Where would I look to see how to do this?

**Tags:** plugin-development, plugins, control-panel, controller, editing


---

## 2 answers

### Answer by username_1 on 2018-06-11. Score: 1

Not sure if you can put it next to the Share button, but check out the **Triggers** feature of Button Box...

> <https://github.com/supercool/buttonbox>

You can create a "Triggers" field, which is just a button that hooks up to JS. Then use the JS to ping your Controller via AJAX.

The button exists as a *field*, so you could just put that field at the top of your field layout. It's not well documented, but it's really easy to do.

> **Comments:**
> **username_0**: Thanks for the reply! I need this to be more tightly integrated via my plugin, though. It's a workflow thing. And I need to link to another CP screen, passing along the entry ID.  

---

### Answer by username_2 on 2019-01-20. Score: 1

I learned in this ticket that you can do this with Craft::$app->getView()->hook() in your plugin's init() method.  It won't put the button in the top near the "Share" button but rather in the sidebar under the settings.  Here's an example (you'll want to customize it to your liking):
Craft::$app->getView()->hook('cp.entries.edit.details', function(array &$context) {

    $entry = $context['entry'];

    if ((int)$entry->sectionId === YOUR_SECTION_ID_HERE) {

        $url = '/your/controller/action/url/';

        return 'My Button';
    }

});


---

