如何使用其他文件中的变量根据页面的URL显示不同的链接?

My PHP is very rusty, it's been years since I did PHP and am having a bit of a brain fart. I am trying to create PHP code so a different link is displayed based on the page you are on (making it so a person is brought to a different Contact Us page based on what page they are on).

The file fieldgroup-simple-group_product_header.tpl does a similar thing by displaying different social media links based on what page you are on. Ideally I want to use the same variable that determines what social media links to display as I do in this PHP file. How do I call a variable from a different file? I tried using an include statement but when I tried to print the variable to make sure it was working nothing is displayed.

I was thinking I could call the variable that identifies page type in the file fieldgroup-simple-group_product_header.tpl and use it to determine what type of link to display.

Thanks,

Doug

Here are the two files:

fieldgroup-simple-group_product_header.tpl

<?php
// $Id: fieldgroup-simple.tpl.php,v 1.1.2.1 2009/02/28 23:56:17 yched Exp $
/**
* @file fieldgroup-simple.tpl.php
* Default theme implementation to display the a 'simple-styled' fieldgroup.
*
* Available variables:
* - $group_name - The group name
* - $group_name_css - The css-compatible group name.
* - $label - The group label
* - $description - The group description
* - $content - The group content
*
* @see template_preprocess_fieldgroup_simple()
*/
?><? //print_r( get_defined_vars()); die();?>
<?php 
if ($content) :  
$content_div_id = $group_name;
$holderId = $group_name . "_holder";
$show_div_class = "show_link_holder";
$hider_link_class = "group_hide_link";
$show_link_class = "group_show_link";
$show_link_id = $group_name ."_show_link";
$show_link_text = $label;
$href = "#" . $content_div_id;
//die( $show_link_text );
?>  
<div class="fieldgroup <?php print $group_name_css; ?>" id="<?=$holderId ?>" title="   <?=$label ?>">
<div class="group_content" id="<?=$content_div_id ?>">
<?php print $content; ?>
<div class="clear"></div>
</div><!--close #<?=$content_div_id ?>-->

</div><!--close #<?=$holderId ?>-->
<?php endif; ?>

And the contact-us.php file code:

<?

//this is the location of the product header file that defines the variable that determines the content type
include '/sites/all/themes/tekzennew/fieldgroup-simple-group_product_header.tpl';
function build_info_form($node)
{
  $node_url = $node->path;
$is_canine = strcasecmp($node_url, CANINE_STUDY_URL) == 0;

$img_src = $is_canine ? "/sites/default/files/case-study-orange.gif" : "/sites/default/files/info-orange.gif";

?>



            <div class="request-info-holder system-sidebar-container">
                <div id="request-info-header" class="system-sidebar-header">
                    <span class="request-form-title">Contact Us</span>
                </div>
                <div id="request-info-content" class="system-sidebar-content">
                <span class="phone">800.248.3669 | 617.464.4500</span>
<?php
if ($a > $b) {
echo "a is bigger than b";
} elseif ($a == $b) {
echo "a is equal to b";
} elseif ($d == $b) {
echo "a is equal to b";
} else {
echo "a is smaller than b";
}
?>

<?php print $group_name; ?><br>
<a href="http://www.tekscan.com/contact-dental"><img src="<?=$img_src ?>" /></a>
<form action="" method="post" >
<input type="image" name="submit" value="Request Info" class="info-button" src="<?=$img_src ?>" />
<!-- product field -->                      
<input type="hidden" name="product" value="<?=$product_name ?>"/>
</form>
</div>
</div>
<?  

In the he contact-us.php file line 41 you are trying to print $group_name. However you are not setting its value in either of these 2 files. Same issue for $content. It looks like you may be missing a file or a few here.