Own Module | Enable Autorefresh partly in View Script

Hello there,

i have created an own Icinga Web 2 module:

The View Script has the following structure:

<div class="controls">...</div>
<div class="content">
<div class="should_not_auto_refresh">
<iframe ... >
<div class="should_auto_refresh">...</div>

So i have enabled autorefresh (set in the controller) to update the page but some parts should not be reloaded.

Why? Because the view script contains an iframe and the content in there needs some time to update.

I tried already the following (without effect):

  • Put iframe outside of content
  • Put iframe in controls div


  • Is there a mechanism in Icinga Web2 to control which parts are reloaded?
  • Until now, i have my knowledge about writing a module from this talk (https://www.youtube.com/watch?v=GR1QguEdilg) … Is there a documentation of how to integrate a module and which further preferences are there?

Cheers, Matze.

Nope. Best is to ask here just like you already did now. :wink:

Try this:



namespace Icinga\Controllers;

use Icinga\Web\Controller;

class TestController extends Controller
    public function separateRefreshAction()
        $this->view->content = 'About to be...';

        $this->getTabs()->add('separate_refresh', [
            'label'     => 'Separate Refresh',
            'url'       => 'test/separate-refresh',
            'active'    => true

    public function separateContentAction()
        $this->view->content = 'Refreshed!';



<div class="controls">
    <?= $this->tabs ?>
<div class="content">
    <!-- Your iframe, or any other content only refreshed by user interaction -->
    <iframe src="<?= $this->href('monitoring/list/services') ?>"></iframe>

        The content that should be automatically refreshed.
        It's wrapped by a container which will be refreshed.

        id: Is required, but it can be arbitrary
        class: Needs to have `container`, can hold additional classes
        data-icinga-refresh: The initial refresh delay, once refreshed this will be what the controller sets
        data-icinga-url: Where the new content should be loaded from. Must not provide layout
    <div id="<?= $this->protectId('separate-content') ?>"
         data-icinga-url="<?= $this->href('test/separate-content') ?>"
        <!-- The initial content. I've used partial() only to re-use the view script, feel free to not use it -->
        <?= $this->partial('test/separate-content.phtml', ['content' => $content]); ?>


<?= $content ?>

Hey Johannes,

    <div id="<?= $this->protectId('separate-content') ?>"
             data-icinga-url="<?= $this->href('test/separate-content') ?>"

Thx for your reply. The solution looks good. To use two different controllers and include one view script in another makes sense.

I will try it and reply if it has worked.

Meanwhile i had a different approach (which is more or less “hacked”) and had limitations. But it worked for my special usecase and maybe it is helpful for someone else:

  • I have used the module.js file to place the iframe in an div inside of the main div of Icinga Web 2 during initial loading of the module.
  • It has worked, but it crashes navigation and window adaption.
  • And it breaks the Icinga Web 2 control of the frame/div.
  • So in the DOM it was some how like:
<div id="main">
   <div id="iframe"></div><!-- added by me -->
   <div id="col1"></div>

BR, Matze

:+1: Ok, it has worked.

Nice to hear! :smiley:

Please consider marking my post as solution, so others can easily identify it.