# How to add button in collection sidebar?

**URL:** <https://discourse.getcockpit.com/t/how-to-add-button-in-collection-sidebar/934>\
**Category:** Support\
**Created:** [July 21, 2019, 7:47am UTC](https://discourse.getcockpit.com/t/how-to-add-button-in-collection-sidebar/934 "2019-07-21T07:47:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitzania](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/bitzania/32/488_2.png) [@bitzania](https://discourse.getcockpit.com/u/bitzania)\
**Post date:** [July 21, 2019, 7:47am UTC](https://discourse.getcockpit.com/t/how-to-add-button-in-collection-sidebar/934/1 "2019-07-21T07:47:18Z")

</div>

Hi there!

I have a collection named Order ( online shopping )  
I’d like to add some buttons in the collection entry sidebar, this button simply changes the entry status and then save it.

 ![Screenshot_4](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/4d8443aa568883abd6991ce17bb23df6fb37de46.png)

I’m thinking to override the entry view and then found out about :

> @trigger(‘collections.entry.aside’

What does it do?  
can it be used for my scenario?  
How to change the entry value on button click and then save it?

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [July 21, 2019, 12:10pm UTC](https://discourse.getcockpit.com/t/how-to-add-button-in-collection-sidebar/934/2 "2019-07-21T12:10:38Z")

</div>

> [@bitzania](#):
>
> What does it do?

It fires the event `collections.entry.aside`.

You can add content via `/config/bootstrap.php` with

```php
$app->on('collections.entry.aside', function() {
    echo '<p style="border:4px solid red">add button here</p>';
});

```

or cleaner:

```php
$app->on('collections.entry.aside', function() {
    
    $text = 'Test';
    $button = 'Change';

    $this->renderView($this->path('pluginname:views/partials/add_button.php'), compact('text', 'button'));
});

```

> [@bitzania](#):
>
> How to change the entry value on button click and then save it?

`add_button.php` should contain something like this (not tested):

```auto
<!-- Lexy templating with double curly brackets - output: <?php echo $text; ?> -->
<p>{{ $text }}</p>

<!-- riot.js with single curly brackets in onclick event -->
<button class="uk-button uk-button-large" value="buttonvalue" onclick="{ changeEntryAndSave }">

    <!-- Lexy templating again -->
    {{ $button }}

</button>

<script>

    changeEntryAndSave = function(e) {

        if (e) e.preventDefault();

        $this.entry.status = 'Shipping';

        $this.update();

        $this.submit();

    }

</script>

```

PS: You can use [markdown syntax highlighting](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code) on discourse by using backticks. It makes code more readable and it prevents copy/paste issues with wrong quotation.
