Just render a Table component



What should I do if I want to use a Agile component as part of another framework?

I want to use PHP and Agile Framework to just render a Table component in my page. So what layout should I use for the App? I do not need the extra staff provided by layout “Centered”. It is not an entire application, I just want to render a Table component.


I have tried the “Generic” layout, but still my Table goes not where I want it, but after all my other html in a div tag.


require ‘init.php’;
require ‘database.php’;
include ‘class_product.php’;

$table = $layout->add(‘Table’);
$table->setModel(new class_product($db));



Each component can render itself. Sometimes object needs to be initialized explicitly. Something like this should work:

$table = new Table();
$table->setModel(new class_product($db));
$html = $table->render();

If it’s not working for you, then it’s a bug. More information on component rendering:



Yes. It works now. I was missing the init() and I thought that render() actually outputs the html and not simply returns it.

The following can be inserted in a TD tag in a html table:


require ‘./vendor/autoload.php’;

$app = new \atk4\ui\App(‘Home Hub’, [‘icon’=>‘user’]);

$layout = $app->layout;

require ‘database.php’;

include ‘class_product.php’;

$table = new \atk4\ui\Table();
$table->setModel(new 'class_product($db));
$html = $table->render();

echo $html;

It works also without the App object, but then no CSS is applied.


I’m glad it worked. If you have any other questions, please ask.