Jump to content

Request URI question


JaredRitchey

Recommended Posts

I'm trying to get this chunk of code to work but I for some reason the code fails to respond correctly.  What I'm after is the entire URI with or without file name to work properly as I comment here below.  I'm almost certain its my syntax in the first line shown here.

 

case "/index.html" || $P == "/" || "$P" == "/index.php": //I WANT THIS TO WORK

//case "index.php":  //ONLY THIS WORKS

 

<?php 
$P=$_SERVER['REQUEST_URI'];
switch ($P) {

// Show Three columns with advertising block on right
case "login.php";
case "privacy.php";
$data = 'threecolumn2.php'; 
break;

// Show Three columns with NO advertising blocks
case "/index.html" || $P == "/" || "$P" == "/index.php":
//case "index.php":
$data = 'threecolumn.php';
break;

// TWO COLUMNS EVERY WHERE ELSE
default:
$data = 'twocolumn.php';
}
?>

 

~ Jared

Link to comment
Share on other sites

Forgot to explain what its for.

 

The idea is to have a sort of variable template engine of sorts where some pages would load the third column while others would always be two columns.  Some however would load a third column with a pair of advertising blocks.

 

Each of the column files are external and use an include statement in the actual template. 

 

If I use this it doesn't work

case "/index.html" || $P == "/" || "$P" == "/index.php":

 

If I use the following its fine

case "/index.php":

case "/index.htm":

case "/index.html":

 

 

Link to comment
Share on other sites

<?php 
  $P=$_SERVER['REQUEST_URI'];
  switch ($P) {

  // Show Three columns with advertising block on right
  case "login.php";
  case "privacy.php";
    $data = 'threecolumn2.php'; 
    break;

// Show Three columns with NO advertising blocks
  case "/index.html":
  case "/":
  case "/index.php":
    $data = 'threecolumn.php';
    break;

// TWO COLUMNS EVERY WHERE ELSE
  default:
    $data = 'twocolumn.php';

}
?>

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.