renfley Posted June 17, 2013 Share Posted June 17, 2013 Hey guys, when every i create a new page we currently pass it via the url like... <a href="?page=home">home</a> So by using the following code. if (isset($_GET['page'])) { include ("includes/" . $_GET['page'] . ".php"); } else{ echo "Welcome Home"; } This method looks like this www.example.com/?page=2 Is there a way other to apply a complete MVC to use only the controler to change the view? so i would have www.example.com/article/ and use a controler to just include? Quote Link to comment https://forums.phpfreaks.com/topic/279249-site-navigation-help/ Share on other sites More sharing options...
trq Posted June 17, 2013 Share Posted June 17, 2013 Is there a way other to apply a complete MVC to use only the controler to change the view? Pardon? Quote Link to comment https://forums.phpfreaks.com/topic/279249-site-navigation-help/#findComment-1436331 Share on other sites More sharing options...
renfley Posted June 17, 2013 Author Share Posted June 17, 2013 LOL just notice my phrase... What i meant was I want to use a controller that sees the url as www.example.com/post/2 instead of www.example.com/?page=2 and include that post and 2. Can i take a controller or write a new one without having to incorporate MVC? Quote Link to comment https://forums.phpfreaks.com/topic/279249-site-navigation-help/#findComment-1436414 Share on other sites More sharing options...
Solution renfley Posted June 17, 2013 Author Solution Share Posted June 17, 2013 Well another issue fixed... For those wondering. I found a lib called dispatch, Does exactly what i need... // include the library include 'dispatch.php'; // define your routes get('/greet', function () { // render a view render('greet-form'); }); // post handler post('/greet', function () { $name = from($_POST, 'name'); // render a view while passing some locals render('greet-show', array('name' => $name)); }); // serve your site dispatch(); You can find the files here... http://noodlehaus.github.io/dispatch/ This will be perfect for my framework... Quote Link to comment https://forums.phpfreaks.com/topic/279249-site-navigation-help/#findComment-1436431 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.