I'm doing a final year project for uni in PHP and I'm currently trying to get my head around the MVC design pattern. I've followed a tutorial on phpit which helped me create a basic MVC system to work from but I'm really struggling to understand how to successfully "split" everything and what is and isn't acceptable.
For example, I'm trying to put all the html for the site in template files so I've got a "header" template which I'm putting at the top of every page (obviously), this should have: "Login | Register" if they're not logged in, and "My Area | Logout" if they're logged in. So...
That's all in the index template file... is it OK to put php logic like that in the template? Or should that be kept to the controller somehow?
Any help/advice would be appreciated. Also if anyone can recommend any books specifically for MVC or design patterns with PHP which you think may help that'd be great too.
For example, I'm trying to put all the html for the site in template files so I've got a "header" template which I'm putting at the top of every page (obviously), this should have: "Login | Register" if they're not logged in, and "My Area | Logout" if they're logged in. So...
Code:
html stuff here.....
<?php
if(!isset($isLogged)){
echo '<a href="login">Login</a> | <a href="register">Register</a>';
}else{
echo '<a href="myarea">My Area</a> | <a href="logout">Logout</a>';
}
?>
bit more html stuff.....
That's all in the index template file... is it OK to put php logic like that in the template? Or should that be kept to the controller somehow?
Any help/advice would be appreciated. Also if anyone can recommend any books specifically for MVC or design patterns with PHP which you think may help that'd be great too.