Closed Iazzetta closed 7 years ago
1. You have correct .htaccess file?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
2. You need to set correct folder root.
For example:
Flight::render('../pages/login', array('title' => "Login"));
Or by the views path (recommended):
Flight::set('flight.views.path', 'pages/');
(...)
Flight::render('login', array('title' => "Login"));
L ;)
@imbr I have correct .htaccess file and correct root folder. The unique difference, is my architecture.
My views folder:
/views
I need set all views folders or i can't create a directory?
Thanks!
Examples of use for your folder structure:
<?php
require 'flight/Flight.php';
Flight::set('flight.views.path', 'views/');
Flight::route('/login', function(){
Flight::render('pages/login', array('title' => "Login"));
});
Flight::start();
?>
L ;)
@imbr not working..
layout.php
<head>
<title>Site - <?php echo $title; ?></title>
</head>
index.php
Flight::set('flight.views.path', 'views/');
Flight::render('layout', array('title' => "Home"));
Flight::route('/login', function(){
Flight::render('pages/login', array('title' => "Login"));
});
The title stay "Home"...
@Iazzetta When you call render, it sends the output immediately. So if you render layout
first and then pages/login
it won't change anything. You need to render the layout last, after you render all your page content. See http://flightphp.com/learn/#views.
Oh nice, so I need render layout.php in each route? For me works. Thanks!
Flight::route('/login', function(){
Flight::render('pages/login', array('title' => "Login"));
Flight::render('layout', array('title' => "Login"));
});
Flight::route('/home', function(){
Flight::render('pages/home', array());
Flight::render('layout', array('title' => "Home"));
});
How I change the layout title? I render my layout and can't change the title.
when I try change nothing happens
and my html: