# Show notification message after model update (from config.php)

**URL:** <https://forum.getkirby.com/t/show-notification-message-after-model-update-from-config-php/34321>\
**Category:** Questions\
**Tags:** v5\
**Created:** [June 27, 2025, 4:21pm UTC](https://forum.getkirby.com/t/show-notification-message-after-model-update-from-config-php/34321 "2025-06-27T16:21:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarkieMark](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/markiemark/32/14308_2.png) [@MarkieMark](https://forum.getkirby.com/u/MarkieMark)\
**Post date:** [June 27, 2025, 4:21pm UTC](https://forum.getkirby.com/t/show-notification-message-after-model-update-from-config-php/34321/1 "2025-06-27T16:21:00Z")

</div>

Hi,

I’m generating “lessons” by clicking a controlpanel button (new in v5), executing my model. The concept works, my model generates the lessons. But I’d like to show a notification message saying “lessons created”! Whatever I try (with my AI friends (🙂 I cannot make the message appear in the control panel.

below my config.php with the code.

Any help is welcome…

```auto
<?php
// site/config/config.php
//
// UPDATED: Using a full Response object for the redirect, which is more reliable.
?>
<?php

return [
    'debug' => true,
    'routes' => [
        [
            'pattern' => '(:all)/generate-lessons',
            'action' => function (string $slug) {
                $kirby = kirby();
                $page = page($slug);

                if (!$page || $page->intendedTemplate()->name() !== 'lessongroup') {
                    return false;
                }

                if ($page->lessonsGenerated()->isTrue()) {
                    $message = 'Lessons have already been generated. To regenerate, turn off the toggle and save first.';
                    $kirby->session()->set('kirby.info', $message);
                    return Kirby\Http\Response::redirect($page->panel()->url());
                }

                try {
                    // Step 1: Generate lessons and get the count.
                    $count = $page->generateLessons();

                    // Step 2: Manually update the page toggle. This is the action.
                    $page->update(['lessonsGenerated' => true]);

                    // Step 3: Set the success message in the session.
                    $message = "{$count} lessons were successfully generated for '{$page->description()}'";
                    $kirby->session()->set('kirby.success', $message);
                    
                    // Step 4: Redirect back to the panel using the Response object.
                    return Kirby\Http\Response::redirect($page->panel()->url());

                } catch (Exception $e) {
                    $kirby->session()->set('kirby.error', $e->getMessage());
                    return Kirby\Http\Response::redirect($page->panel()->url());
                }
            }
        ]
    ]
];

```

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [June 27, 2025, 4:23pm UTC](https://forum.getkirby.com/t/show-notification-message-after-model-update-from-config-php/34321/2 "2025-06-27T16:23:37Z")

</div>

There is currently no way to trigger a notification message in the Panel from the PHP side, only in your JavaScript plugin code (if you have any). The JS docs for notifications:  
[https://lab.getkirby.com/public/lab/internals/panel/notification](https://lab.getkirby.com/public/lab/internals/panel/notification)

There is an idea thought to add this feature which you could upvote: [https://feedback.getkirby.com/669](https://feedback.getkirby.com/669)

---

<div class="post-metadata">

**Author:** ![MarkieMark](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/markiemark/32/14308_2.png) [@MarkieMark](https://forum.getkirby.com/u/MarkieMark)\
**Post date:** [June 27, 2025, 4:25pm UTC](https://forum.getkirby.com/t/show-notification-message-after-model-update-from-config-php/34321/3 "2025-06-27T16:25:39Z")

</div>

Thanks for your quick respons, saves me a ton of searching!!

Have a great day!
