Jump to content

Site Navigation Help?


renfley
Go to solution Solved by 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
Share on other sites

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?

Link to comment
Share on other sites

  • Solution

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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