Jump to content

Help with current folder & subfolders of domain


anthelo

Recommended Posts

Hi,

Im having this peace of code

<?php
$requested = empty($_SERVER['REQUEST_URI']) ? false : $_SERVER['REQUEST_URI'];
switch (  $requested ) {
case '/videos/':
$content_title = 'Videos Home Directory';
break;
default:
$content_title = 'Welcome to my Website!';
}
?>

What im trying to do is when im on the domain www.mydomain.com will show $content_title . My problem is when im trying for example www.mydomain.com/videos/ everything is ok but when im on www.mydomain.com/videos/something_else/ I want the the same title again

Any help please?

 

not working :(

 

This is what my code now is look like.

 

<?php
$requested_parts = explode('/', $requested);
$requested = empty($_SERVER['REQUEST_URI']) ? false : $_SERVER['REQUEST_URI'];
switch (  $requested_parts ) {
case '/videos/':
$content_title = 'Videos Home Directory';
break;
default:
$content_title = 'Welcome to my Website!';
}
?>

 

You need to set $requested before you use explode() on it.  Switch the order of the first two lines.

 

Also $requested_parts[1] is what you need to look at, not $requested_parts.  And the value to compare against is "videos", not "/videos/", because explode() will remove all the slashes.

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.