PHP code example of walter-a-jablonowski / damn-small-engine

1. Go to this page and download the library: Download walter-a-jablonowski/damn-small-engine library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

walter-a-jablonowski / damn-small-engine example snippets


// Some config

$config = DSEConfig::instance();

if( $env == DEBUG )     $config->preferMinified( false );  // should use minified version ?
elseif( $env == PROD )  $config->preferMinified( true );

// $config->setControlsFolder('controls/');
$config->setDirPrefix( 'my_' );  // a folder prefix that you can leave out on new View( ... )


// Data

$dbRows = ...


// Build

$page = new WebPage( ' use ListView::buildList( ... );
                                     //   for the whole table, see basic sample

foreach( $dbRows as $id => $dbRow )  // if you prefer, you also could use a for loop in
{                                    //   html instead, see "misc samples"
  $row = $page->newView( 'controls/table/row' );

  $row->field1 = $dbRow['col_1'];    // you could also use: $row->setValues( $dbRow );
  $row->field2 = $dbRow['col_2'];
  
  $rows->addView( $row );
}

$table->addSubView( 'content', $rows );
$layout->addSubView( 'table', $table );
$page->attachContent( $layout );


echo $page->render();