Jump to content

[SOLVED] Small page mapping array question. Default page?


Darkstasis

Recommended Posts

I got help before with adding in page arrays. I'm using an example that I was given to learn.

Basically, I have index.php and 3 pages of content.

I add in the array and 3 links to toggle between pages with index.php showing no content pages already.

This has worked fine, but now I'd like to know how I can get news.php as a default when index.php loads?

 

$page_mapping = array(

  'page1' => 'content/page1content.php',

  'page2' => 'content/page2content.php',

  'news' => 'content/news.php',

);

 

$page = $_REQUEST['page'];

if (!empty($page_mapping[$page])) {

  include_once($page_mapping[$page]);

}

$page_mapping = array(
  'page1' => 'content/page1content.php',
  'page2' => 'content/page2content.php',
  'news' => 'content/news.php',
);

$page = $_REQUEST['page'];
if (!empty($page_mapping[$page])) {
  include_once($page_mapping[$page]);
} else {
  include_once "index.php";
}

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.