Jump to content

TheTrooper123

New Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by TheTrooper123

  1. Hi all, I have built a basic router for my slug urls to work. However I'm trying to make it so that if a page is created (maybe for a blog) that the router would automatically work without have to hard code it in.

    This is my current code where I've hard coded the link 'post-one' to work:

        
    $request = $_SERVER['REQUEST_URI'];
    switch ($request) {
    
    case '/blog/post-one':
             $_GET['page_slug'] = 'post-one';
            require __DIR__ . '/views/blog/page.php';
            break;

    The below code won't work but hopefully gives an idea what I am trying to acheive where if a new post is created the 'page_slug' is retrieved and the dynamic link is created. Anyone know how something like this could work?

     

    $request = $_SERVER['REQUEST_URI'];
    switch ($request) {
    
    	case '/blog/'.$_GET['page_slug'].'':
             $_GET['page_slug'] = $rows["page_slug"];
            require __DIR__ . '/views/blog/page.php';
            break;

    Any help most appriciated.

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