Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

I'm a new user

posted by juanitodelcielo 9 years ago

Hi there, I used to use CodeIgnter but after a yer wating for PHP5 I get bored.

Today I started to use Flourish and I want to know som best practices using Flourish

VIEWS

#!text/html
$db = new fDatabase('mysql', 'database', 'root', 'root');

$items = $db->query('SELECT * FROM items LIMIT 3');

$template = new fTemplating('views/');

$template->set('page', 'index.php');
$template->set('items', $items);

$template->place('pagina');
#!text/html
<html>
	
	<head>
	
		<title></title>
	
	</head>
	
	<body>
		<ul>
		<?php foreach ( $items as $item ) : ?>
			<li><?php echo $item['barcode']; ?></li>
		<?php endforeach; ?>
		</ul>
	</body>
	
</html>

I get a beautiful Invalid argument supplied for foreach() so I tried to use a include instead place() and it works fine.

Code Igniter way

$data['items'] = $this->db->get('items', 3);

$this->load->view('index', $data);

When you place a file in fTemplating, the file is included inside of the scope of the fTemplating instance. Thus, inside of your view you need to call $this->get() to retrieve values.

<html>
    <head>
        <title></title>
    </head>
    <body>
        <ul>
        <?php foreach ( $this->get('items') as $item ) : ?>
            <li><?php echo $item['barcode']; ?></li>
        <?php endforeach; ?>
        </ul>
    </body>
</html>
posted by wbond 9 years ago