So I am attempting to parse out the URL, so that I can get a specific page template to be used for a specific URL; if the URL is example.com/team, then use page-team.tpl.php.
However, when I do this, the URL I am getting (via $_GET['q']) always seems to be the URL from where I was, not the one where I am currently at. If I directly navigate to example.com/team/surf, it gives me "team/surf"; if I go to example.com/team it gives
"team/surf." If I refresh the page, it will then give me the desired one.
I dropped this code into my template.php file.
function theme_preprocess(&$vars, $hook) {
switch ($hook) {
case 'page':
$normal_path = trim($_GET['q'], '/');
$path_alias = drupal_get_path_alias($normal_path);
$alias_parts = explode('/', $path_alias);
if (($alias_parts[0] === 'team') && (count($alias_parts)) == 1) {
$vars['template_file'] = 'page-team';
}
break;
}
Do you have any idea on what is going on here?
$_GET['q']is normally updated with the current value get from the page request. I have never seen that value being not correct. There could be code that alters that value, but from what being reported is not possible to know that. – kiamlaluno♦ Feb 11 at 21:09