SourceForge.jp

View

  You can choice way to write HTML from next four ways.

  • Write in PHP file
  • Separate PHP file and template like smarty.( Faster than smarty because of no parsing )
  • Prepare Common template for all pages, and write in PHP file.
  • Prepare Common template for all pages, and Separate PHP file and template.

Write in PHP file

  It's comfortable to create small personal program.

test.php
<?php
    require_once( "cheetan.php" );

function action( &$c )
{
    $c->set( "msg", "Hello" );
}
?>
<html>
<body>
<h1><?php print $data["msg"]; ?></h1>
</body>
</html>

Separate PHP file and template.

  You can separate action part of PHP and display part like smarty.

test.php
<?php
    require_once( "cheetan.php" );

function action( &$c )
{
    $c->set( "msg", "Hello" );
}
?>
test.html
<html>
<body>
<h1><?php print $data["msg"]; ?></h1>
<!-- in this case, you can use following expression -->
<h2><?php echo $msg; ?></h2>
</body>
</html>

If you specify nothing, template file name will become 'your php file name.html'. Use function 'SetViewFile( string filename )' of Controller if you want to specify file name.

Prepare common template for all pages and wirte in PHP file

You can use common template for all pages. Write only HTML of contents by this way. Specify template file name by function 'SetTemplateFile( string filename ) of Controller if you want to use this way.

template.html
<html>
<body>
<?php contents( $data ); ?>
<!-- in common template, you can use following expression -->
<?php echo $msg; ?>
</body>
</html>
test.php
<?php
    require_once( "cheetan.php" );

function action( &$c )
{
    $c->set( "msg", "Hello" );
}
function contents( $data )
{
?>
<h1><?php print $data{"msg"]; ?></h1>
<?php
}
?>

Prepare common template for all pages and separate PHP file and template.

You can use common template for all pages and separate file of action part and display part. Way of write of template.html is differ from former way a little.

template.html
<html>
<body>
<?php $this->content( $data ); ?>
<!-- in common template, you can use following expression --> <?php echo $msg; ?> </body> </html>
test.php
<?php
    require_once( "cheetan.php" );

function action( &$c )
{
    $c->set( "msg", "Hello" );
}
?>
test.html
<h1><?php print $data{"msg"]; ?></h1>
<!-- in this case, you can use following expression --> <h2><?php echo $msg; ?></h2>