Jump to content

Site Navigation Help?


renfley

Recommended Posts

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?

 

 

 

 

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/279249-site-navigation-help/
Share on other sites

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.