Funny thing is, I reversed engineered their code a little to find out how they are doing it in the theme, and it looks as though they simply take the default value of the cforms form for that field which is "your-subject" and just replace it with a variable that grabs the page title. I can add "your-subject" to the gforms form and it still brings up the agent's name and not title of the page.
Their code in the variables file is:
$agentcontactform = get_post_meta($post->ID, "contactformshortcode_value", true);
Their code to display the info is:
?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
$agent = "";
$agent2 = "";
include get_template_directory() . '/includes/variables.php';
$contactformsubject = get_the_title();
?>
The sidebar code:
$theagent = $agent;
$theagent2 = $agent2; ?>
<?php include get_template_directory() . '/includes/related.php'; ?>
<?php if (get_option('wp_site') == "Real Estate") { ?>
<?php if (get_option('wp_showcontactform') == "show") { ?>
<div id="contactagent">
<?php
global $wpdb;
$sql = " SELECT *
FROM $wpdb->posts AS p
WHERE p.post_type = 'agent'
AND p.post_title = '". $theagent ."'";
$agentarray = $wpdb->get_results($sql);
$sql2 = " SELECT *
FROM $wpdb->posts AS p
WHERE p.post_type = 'agent'
AND p.post_title = '". $theagent2 ."'";
$agentarray2 = $wpdb->get_results($sql2);
?>
<?php if ($agentarray) { ?>
<?php foreach ($agentarray as $post) { ?>
<?php setup_postdata($post); ?>
<?php include get_template_directory() . '/includes/variables.php' ?>
<h3>
<?php echo get_option('wp_agentcontactustext'); ?>
</h3>
<div class="agentbox">
<h4 class="bar"><?php the_title() ?></h4>
<?php
$arr_sliderimages = get_gallery_images();
if ($arr_sliderimages) { ?>
<?php $resized = aq_resize($arr_sliderimages[0], 80, 100, true); ?>
<img width="80" height="100" alt="" src="<?php echo $resized ?>" />
<?php } ?>
<p>
<?php if ($agenttitle) { ?>
<strong><?php echo $agenttitle ?></strong><br />
<?php } ?>
<?php if($agentphoneoffice) { ?>
<?php echo get_option('wp_agentphone1') . ": " . $agentphoneoffice ?><br />
<?php } ?>
<?php if($agentphonemobile) { ?>
<?php echo get_option('wp_agentphone2') . ": " . $agentphonemobile ?><br />
<?php } ?>
<?php if($agentfax) { ?>
<?php echo get_option('wp_agentfax') . ": " . $agentfax ?><br />
<?php } ?>
<a href="<?php the_permalink() ?>"><?php echo get_option('wp_otherlistings') ?></a>
</p>
<div style="clear: left;"></div>
<?php if ($agentarray2) { ?>
<a class="btn btn-block" data-toggle="collapse" data-target="#agent1"><?php echo get_option('wp_contactformbutton_text') ?></a>
<div id="agent1" class="collapse"><?php echo do_shortcode($agentcontactform); ?></div>
<?php } else { ?>
<?php echo do_shortcode($agentcontactform); ?>
<?php } ?>
</div>
<?php } ?>
<?php } else { ?>
<h3><?php echo get_option('wp_contactustext') ?></h3>
<?php echo do_shortcode(stripslashes(get_option('wp_contactshortcode'))); ?>
<?php } ?>
<?php if ($agentarray2) { ?>
<?php foreach ($agentarray2 as $post) { ?>
<?php setup_postdata($post); ?>
<?php include get_template_directory() . '/includes/variables.php' ?>
<div class="agentbox">
<h4 class="bar"><?php the_title() ?></h4>
<?php
$arr_sliderimages = get_gallery_images();
if ($arr_sliderimages) { ?>
<?php $resized = aq_resize($arr_sliderimages[0], 80, 100, true); ?>
<img width="80" height="100" alt="" src="<?php echo $resized ?>" />
<?php } ?>
<p>
<?php if ($agenttitle) { ?>
<strong><?php echo $agenttitle ?></strong><br />
<?php } ?>
<?php if($agentphoneoffice) { ?>
<?php echo get_option('wp_agentphone1') . ": " . $agentphoneoffice ?><br />
<?php } ?>
<?php if($agentphonemobile) { ?>
<?php echo get_option('wp_agentphone2') . ": " . $agentphonemobile ?><br />
<?php } ?>
<?php if($agentfax) { ?>
<?php echo get_option('wp_agentfax') . ": " . $agentfax ?><br />
<?php } ?>
<a href="<?php the_permalink() ?>"><?php echo get_option('wp_otherlistings') ?></a>
</p>
<div style="clear: left;"></div>
<a class="btn btn-block" data-toggle="collapse" data-target="#agent2"><?php echo get_option('wp_contactformbutton_text') ?></a>
<div id="agent2" class="collapse"><?php echo do_shortcode($agentcontactform); ?></div>
</div>
<?php } ?>
<?php } ?>
</div><!-- end contact agent -->
<?php }} ?>
<?php if(get_option('wp_site') == "Car Sales") { ?>
<?php if (get_option('wp_showcontactform') == "show") { ?>
<div id="listingcontact">
<?php } ?>
<h3 class="bar" id="contact"><?php echo stripslashes(get_option('wp_contactustext')); ?></h3>
<?php echo do_shortcode(stripslashes(get_option('wp_contactshortcode'))); ?>
</div><!-- end listing contact -->
<?php } ?>
<script type="text/javascript">
$("input[name='your-subject']").val('<?php echo $contactformsubject ?>');
</script>
Posted 11 years ago on Friday December 28, 2012 |
Permalink