hemanthpyro - 7 months ago

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.

Answer

ryanthompson - 7 months ago

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 - 7 months ago

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

piterden - 7 months 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 - 7 months ago

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

ryanthompson - 7 months 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 - 7 months ago

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 - 7 months ago

Using Bootbox works .Thanks ^_^

hemanthpyro - 7 months ago

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

ryanthompson - 7 months 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?