Jump to content

Page redirection, loading wrong page


imawake

Recommended Posts

Hi,

 

I have a file called content.php which contains the following code:

 

<?php 

// if it isn't a main section get the homepage
if ($subDir == null) {
include ($_SERVER['DOCUMENT_ROOT'] . '/dev/includes/content_pages/home/home.php');
}

// or if the url is a main section, get that main section
if ($subDir != null && $childDir == null) {
include ($_SERVER['DOCUMENT_ROOT'] . '/dev/includes/content_pages/' . $subDir . '/' . $subDir . '.php');
}

// If the url is a subpage of the main section get that content
if ($subDir != null && $childDir != null) {
include ($_SERVER['DOCUMENT_ROOT'] . '/dev/includes/content_pages/' . $subDir . '/' . $pageTitle . '.php');
}

?>

 

The problem I'm having is that I need my subpages to be displayed if I go to those subpages. At the moment, I'm seeing the homepage when I try to load a subpage like products.php. I'm new to php and if anyone can offer suggestions, I would greatly appreciate the help.

 

If you need more detail, please let me know.

 

Thanks

 

 

Link to comment
Share on other sites

Are they being passed in somewhere? $_GET variables?

 

// If the url is a subpage of the main section get that content
if ($subDir != null && $childDir != null) {
include ($_SERVER['DOCUMENT_ROOT'] . '/dev/includes/content_pages/' . $subDir . '/' . $pageTitle . '.php');
}

I think $childDir should be $pageTitle.

 

Looks like the variables aren't defined so it always defaults to the first option which is the home page. You could try to echo them and see if they are set or not or use isset on them.

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.