first things first:
Icinga Web 2 version: 2.12.2
Icinga 2 version: r2.14.5-1
PHP version: 8.0.30
Server operating system: Red Hat Enterprise Linux 8.10
Issue description:
Because of very special requirements, I had to create my own reporting pages using the reporting module. I’m just using some parts of the original module to get the view integrated into Icinga (reporting section).
Everything is working as expected, except that the output is aligned at the bottom of the page. That’s not noticeable, if we have many lines returned, but if there are just a few, the page looks strange (empty with lines at the bottom).
I’m not a PHP developer, so it would take me days or weeks to find the cause, but maybe some of you know immediately how to fix that?
That’s what I use from the original code (shortened to the important parts):
<?php
namespace Icinga\Module\Reporting\Controllers;
use Icinga\Module\Reporting\Database;
use Icinga\Module\Reporting\Web\Controller;
use ipl\Html\Table;
use ipl\Sql\Select;
class HostController extends Controller
{
public function availabilityAction()
{
$table = new Table();
$db_handle=Database::get();
$stmt = $db_handle->prepare("<some statement>");
$stmt->execute();
$result = $stmt->setFetchMode(\PDO::FETCH_ASSOC);
echo "<table>";
echo <some table_content>
echo "</table>";
$this->setTitle('Host Availability Report');
$this->addContent($table);
}
}
?>
As described already, the table is getting displayed as intended with the correct content. I just want to know how I can get it from the bottom of the page to the top.
Thanks a lot, I rewrote the code that way and the table is displayed at the top now. Unfortunately it just pushed the issue into another place. I have some text and a form that needs to be displayed above the table. But the “addContent” function is placing the table at the top of the page, instead in the order of the code.
I tried to move the additional content to the top with a “style” tag and “position: absolute”. But now the informational content is overlapping with the table. They are both displayed at the top of the page.
I’m able to get the required order by calling “addContent” for each element, but I didn’t find a way yet to get 2 items in one row (some text and a form in one line).
without the full code this is very hard to tell.
addContent adds content after the last thing that was added.
if yoy need some other grouping you can always put something in a div container
don’t start with position and styletags to fix this it only gets worse.
upload the code on github or here but without the code it is not possible to provide more help
This will display “some content” on top of the page and “Header” at the bottom.
Some more detailed documentation about available options when defining forms and how to use them would have helped me as well, but with the help of your links and some time spent in testing I could find out, what I needed.