Hi,

I would like to be able to check for which page drupal is on in my site. Basic the structure of the code is like this

if (page is equal to front) {

do this

} else if (page is equal to groups) {

do this

} else if (page is equal to events) {

do this

} else {

then do this
}

I would put this function in my template page and call it from my page.tpl.php page. I would like to pass the page to the function to run the check to return the information for printing on the page.tpl.php. Basically I would like to be able to have Drupal know which page it is on and print different information for that page in a box though code.
Might be better in a select statement but you get my point. Thanks for any help.

Comments

WorldFallz’s picture

if you're using a phptemplate based theme you have "$is_front" available in page.tpl.php. To test for groups and/or events, you'd probably have to check the $node->type.

The logic might look like:

<?php
if ($is_front) {
  //do something for front page

}
elseif ($node->type == "group_content_type") {
  //do something for group node pages

}
elseif ($node->type == "event_content_type") {
  //do something for event node pages

}
else {
  //default: do something for all other pages

}
?>

Untested-- just a guess.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

bm123’s picture

Thanks for your help I will give this a try and post back.

bm123’s picture

This is what I did, don't know if it is the best way to do this.

I run this function in the page tpl to show the icons for the pages that I would like them to show up on. otherwize no popup icon on that page.

function helpicons () {
	$string = split("/", $_REQUEST["q"]); 
	list($start, $end) = $string;
	if ($_REQUEST["q"]=="" && !(variable_get('site_frontpage', 'node')==$_REQUEST["q"])) {
	        
	        $output .= t('<a class="icon" href="#" id="pop1" onclick="show(\'popUp1\')" onblur="hide(\'popUp1\')"><img src="' . base_path() . 'sites/all/themes/theme/images/icon.gif" /></a>');
	
	
 	} 
	
	                 switch ($start) {
	
	                 case 'front':
	                        $output .= t('<a class="icon" href="#" id="pop1" onclick="show(\'popUp1\')" onblur="hide(\'popUp1\')"><img src="' . base_path() . 'sites/all/themes/theme/images/icon.gif" /></a>');
	                        break;
	
	                case 'og':
	                        $output .= t('<a class="icon" href="#" id="pop1" onclick="show(\'popUp1\')" onblur="hide(\'popUp1\')"><img src="' . base_path() . 'sites/all/themes/theme/images/icon.gif" /></a>');
	                         break;
	
	                case 'event':
	                        $output .= t('<a class="icon" href="#" id="pop1" onclick="show(\'popUp1\')" onblur="hide(\'popUp1\')"><img src="' . base_path() . 'sites/all/themes/theme/images/icon.gif" /></a>');
	                        break;

                        }

return $output;

}

I run this function in my div for hidden javascript box this places the different content in each of the pop up boxes for each different page. This is on my template page.

function checkcontent () {
		$string = split("/", $_REQUEST["q"]); // gets the piece before the back slash to compare with
		list($start, $end) = $string; // gives me the two pieces I want the first one
		if ($_REQUEST["q"]=="" && !(variable_get('site_frontpage', 'node')==$_REQUEST["q"])) {
                          $output .= t('Here is the output for the main page');
                }

                switch ($start) {
                            case 'front': // checks the start variable to see which page it is then puts the information in the popup div on the page for help.
	                         $output .= t('output if they're first logged in and "q" = the front page');
                                 break;
                            case 'og':
                                  $output .= t('output if they're on the groups page');
                                 break;
                            case 'event':
                                  $output .= t('output if they're on the events page');
                                 break;
                  }
                   return $output;
}

This is for Drupal 5.x