Adding custom action to post list in admin panel
Created 6 years ago by hemanthpyro

I have a custom field "live_video"(checkbox) in my post.I want to create an action(similar to delete action) in the post list for this field "live_video" in such a way that when I check the post (one post at a time) and click the "live_video" button(need to show the button only for "video" category) I need to show a "pop up" with a message "Do you really want to make this post live ". When I click the "Yes" button in the pop up ,I need to make the current post (video) "live" and all other post should be normal(at a time only one video can be live),I need to remove video(post) which was "live" before clicking the button.

ryanthompson  —  6 years ago Best Answer

Bootbox is included in the admin theme so you can use that too. Here's an example of how I use the confirm function for it: https://github.com/pyrocms/accelerant-theme/blob/1.0/resources/js/theme/confirm.js

piterden  —  6 years ago

Where do you want to have this button? In the Control Panel, or either in frontend?

piterden  —  6 years ago
    /**
     * Unset home pages.
     *
     * @return void
     */
    public function unsetHomePages()
    {
        $this->model->where('home', true)->update(['home' => false]);
    }

Look here ^. Home should be only one. You could make it analogically with pages-module.

hemanthpyro  —  6 years ago

I need the button in control panel .I didn't get you piterden

ryanthompson  —  6 years ago

You can add some assets to the form and listeners in JS to the input - use the $assets property to add stuff like this: https://pyrocms.com/documentation/streams-platform/1.3/ui/tables#including-assets

ryanthompson  —  6 years ago Best Answer

Bootbox is included in the admin theme so you can use that too. Here's an example of how I use the confirm function for it: https://github.com/pyrocms/accelerant-theme/blob/1.0/resources/js/theme/confirm.js

hemanthpyro  —  6 years ago

Using Bootbox works .Thanks 😊

hemanthpyro  —  6 years ago

Is there any option to show this button only for a particular "category" in the post list in control panel?

ryanthompson  —  6 years ago

If you are displaying this post-creation (you know the category) then you can use a closure or something to conditionally show the button yes. Is this in a table builder or where is this functionality?