![]() |
|
||||||
|
|
Thread Tools | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Hi there,
I'm currently working on a site for a client. I have opted to go Corporate Theme (although I'm having a problem on the home page, which is waiting for a solution on the Corporate board), but I'd like to incorporate the Listing page from the Agent Theme. What is the best way to go about doing this? I remember using these boards before to learn how to customize the fields on the listing page, which I did with great success. While researching that problem, I remember someone saying that that listing page was a customized plugin. Is it as simple as using that plugin? If so, what is that plugin? If not, what is my best option? Thanks so much. |
|
#2
|
|||
|
|||
|
Hi,
If you look at Agent you will see there's a file called write-panel.php which creates the customised metaboxes in the Post Editor, and listing.php which displays the content of these metaboxes (basically, custom fields). The Single Post Templates plugin, also supplied with Agent (download a fresh copy of the theme - the plugin was updated for 2.9). The Single Post Template plugin is used to decide whether a post should be displayed by listing.php or the default template (index.php). Look closely at write-panel.php and listing.php in order to understand how they relate to each other. Pay particular attention to the contents of write-panel.php to see how the variables in the various functions are used. Hope this helps!
__________________
Ade Themessence - Studiograsshopper WordPress plugins: Dynamic Content Gallery | Reveal Page Templates | Custom Taxonomies Menu Widget Check out the Genesis and Child Theme tutorials before posting your question - and please provide YOUR URL! Make Andrea happy - read her Firebug tutorial and save yourself loads of time and effort. |
|
#3
|
|||
|
|||
|
Hi there,
Thanks again for the help. I've begun chipping away at this today. All seemed to be going OK until I went to actually post. While the new template is in the dropdown in the back end, none of the extra fields are. I assume this is a problem with the back end talking to write-panel.php? I uploaded it to my Corporate Theme in the same place where it's located on the Agent Theme (although I think I had to create a Tools folder). Do you know why they might not be talking? Thanks again. |
|
#4
|
|||
|
|||
|
You would have to show me the two files (listing.php and write-panel.php).
__________________
Ade Themessence - Studiograsshopper WordPress plugins: Dynamic Content Gallery | Reveal Page Templates | Custom Taxonomies Menu Widget Check out the Genesis and Child Theme tutorials before posting your question - and please provide YOUR URL! Make Andrea happy - read her Firebug tutorial and save yourself loads of time and effort. |
|
#5
|
|||
|
|||
|
Hi,
Here they are. Left them with default agent settings, as I wanted to get it working before customizing the fields. listing.php Code:
<?php
/*
Single Post Template: Wine Description
*/
?>
<?php get_header(); ?>
<div id="content">
<div id="contentleft">
<div class="postarea">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h5><?php _e("Featured Property", 'studiopress'); ?></h5>
<h1><?php the_title(); ?></h1>
<div class="date">
<p><?php _e("Property Type:", 'studiopress'); ?> <?php the_category(', ') ?> <?php edit_post_link('(Edit)', '', ''); ?></p>
</div>
<?php the_content(__('Read more'));?><div class="clear"></div>
<!--
<?php trackback_rdf(); ?>
-->
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.', 'studiopress'); ?></p><?php endif; ?>
</div>
<div id="listing">
<h4><?php _e("Property Details", 'studiopress'); ?></h4>
<div class="listing-left">
<p><b><?php _e("Listing Price:", 'studiopress'); ?> </b><?php echo get_post_meta($post->ID, "_listing_price", true); ?></p>
<p><b><?php _e("Address:", 'studiopress'); ?> </b><?php echo get_post_meta($post->ID, "_address", true); ?></p>
<p><b><?php _e("City:", 'studiopress'); ?> </b><?php echo get_post_meta($post->ID, "_city", true); ?></p>
<p><b><?php _e("State:", 'studiopress'); ?> </b><?php echo get_post_meta($post->ID, "_state", true); ?></p>
<p><b><?php _e("Zip Code:", 'studiopress'); ?> </b><?php echo get_post_meta($post->ID, "_zip_code", true); ?></p>
</div>
<div class="listing-right">
<p><b><?php _e("MLS #:", 'studiopress'); ?> </b><?php echo get_post_meta($post->ID, "_mls", true); ?></p>
<p><b><?php _e("Square Feet:", 'studiopress'); ?> </b><?php echo get_post_meta($post->ID, "_square_feet", true); ?></p>
<p><b><?php _e("Bedrooms:", 'studiopress'); ?> </b><?php echo get_post_meta($post->ID, "_bedrooms", true); ?></p>
<p><b><?php _e("Bathrooms:", 'studiopress'); ?> </b><?php echo get_post_meta($post->ID, "_bathrooms", true); ?></p>
<p><b><?php _e("Basement:", 'studiopress'); ?> </b><?php echo get_post_meta($post->ID, "_basement", true); ?></p>
</div>
<div class="clear"></div>
<div class="listing-bottom">
<p><b><?php _e("Additional Features:", 'studiopress'); ?> </b><?php echo get_post_meta($post->ID, "_additional_features", true); ?></p>
</div>
</div>
<div class="clear"></div>
<?php // begin code which checks to see if any property listing photos have been added ?>
<?php if( get_post_meta($post->ID, "_photo_1_large", true) ): ?>
<div class="photos">
<h4><?php _e("Additional Photos", 'studiopress'); ?></h4>
<?php if( get_post_meta($post->ID, "_photo_1_large", true) ): ?>
<a href="<?php echo get_custom_field('_photo_1_large'); ?>" rel="lightbox" title="<?php the_title(); ?>"><img class="thumb-archive" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "_photo_1_large", $single = true); ?>&h=<?php echo get_theme_mod('property_thumb_height'); ?>&w=<?php echo get_theme_mod('property_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<?php endif; ?>
<?php if( get_post_meta($post->ID, "_photo_2_large", true) ): ?>
<a href="<?php echo get_custom_field('_photo_2_large'); ?>" rel="lightbox" title="<?php the_title(); ?>"><img class="thumb-archive" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "_photo_2_large", $single = true); ?>&h=<?php echo get_theme_mod('property_thumb_height'); ?>&w=<?php echo get_theme_mod('property_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<?php endif; ?>
<?php if( get_post_meta($post->ID, "_photo_3_large", true) ): ?>
<a href="<?php echo get_custom_field('_photo_3_large'); ?>" rel="lightbox" title="<?php the_title(); ?>"><img class="thumb-archive" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "_photo_3_large", $single = true); ?>&h=<?php echo get_theme_mod('property_thumb_height'); ?>&w=<?php echo get_theme_mod('property_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<?php endif; ?>
<?php if( get_post_meta($post->ID, "_photo_4_large", true) ): ?>
<a href="<?php echo get_custom_field('_photo_4_large'); ?>" rel="lightbox" title="<?php the_title(); ?>"><img class="thumb-archive" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "_photo_4_large", $single = true); ?>&h=<?php echo get_theme_mod('property_thumb_height'); ?>&w=<?php echo get_theme_mod('property_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<?php endif; ?>
<?php if( get_post_meta($post->ID, "_photo_5_large", true) ): ?>
<a href="<?php echo get_custom_field('_photo_5_large'); ?>" rel="lightbox" title="<?php the_title(); ?>"><img class="thumb-archive" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "_photo_5_large", $single = true); ?>&h=<?php echo get_theme_mod('property_thumb_height'); ?>&w=<?php echo get_theme_mod('property_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<?php endif; ?>
<?php if( get_post_meta($post->ID, "_photo_6_large", true) ): ?>
<a href="<?php echo get_custom_field('_photo_6_large'); ?>" rel="lightbox" title="<?php the_title(); ?>"><img class="thumb-archive" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "_photo_6_large", $single = true); ?>&h=<?php echo get_theme_mod('property_thumb_height'); ?>&w=<?php echo get_theme_mod('property_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<?php endif; ?>
<?php if( get_post_meta($post->ID, "_photo_7_large", true) ): ?>
<a href="<?php echo get_custom_field('_photo_7_large'); ?>" rel="lightbox" title="<?php the_title(); ?>"><img class="thumb-archive" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "_photo_7_large", $single = true); ?>&h=<?php echo get_theme_mod('property_thumb_height'); ?>&w=<?php echo get_theme_mod('property_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<?php endif; ?>
<?php if( get_post_meta($post->ID, "_photo_8_large", true) ): ?>
<a href="<?php echo get_custom_field('_photo_8_large'); ?>" rel="lightbox" title="<?php the_title(); ?>"><img class="thumb-archive" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "_photo_8_large", $single = true); ?>&h=<?php echo get_theme_mod('property_thumb_height'); ?>&w=<?php echo get_theme_mod('property_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<?php endif; ?>
<?php if( get_post_meta($post->ID, "_photo_9_large", true) ): ?>
<a href="<?php echo get_custom_field('_photo_9_large'); ?>" rel="lightbox" title="<?php the_title(); ?>"><img class="thumb-archive" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "_photo_9_large", $single = true); ?>&h=<?php echo get_theme_mod('property_thumb_height'); ?>&w=<?php echo get_theme_mod('property_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<?php endif; ?>
<?php if( get_post_meta($post->ID, "_photo_10_large", true) ): ?>
<a href="<?php echo get_custom_field('_photo_10_large'); ?>" rel="lightbox" title="<?php the_title(); ?>"><img class="thumb-archive" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "_photo_10_large", $single = true); ?>&h=<?php echo get_theme_mod('property_thumb_height'); ?>&w=<?php echo get_theme_mod('property_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php // end code ?>
<div class="clear"></div>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
write-panel.php Code:
<?php
/*
Plugin Name: Add Meta Boxes
Plugin URI: http://www.nathanrice.net/
Description: Allows you to add boxes and fields to the Write Post panel, and store the value as a custom field.
Version: 1.0
Author: Nathan Rice
Author URI: http://www.nathanrice.net/
*/
//A simple function to get data stored in a custom field
if(!function_exists('get_custom_field')) {
function get_custom_field($field) {
global $post;
$custom_field = get_post_meta($post->ID, $field, true);
echo $custom_field;
}
}
// Adds a custom section to the "advanced" Post and Page edit screens
function sp_add_custom_box() {
if( function_exists( 'add_meta_box' )) {
add_meta_box( 'sp_custom_box_1', __( 'General Property Info', 'sp' ), 'sp_inner_custom_box_1', 'post', 'normal', 'high' );
add_meta_box( 'sp_custom_box_2', __( 'Property Details', 'sp' ), 'sp_inner_custom_box_2', 'post', 'normal', 'high' );
add_meta_box( 'sp_custom_box_3', __( 'Property Photos', 'sp' ), 'sp_inner_custom_box_3', 'post', 'normal', 'high' );
}
}
/* Prints the inner fields for the custom post/page section */
function sp_inner_custom_box_1() {
global $post;
// Use nonce for verification ... ONLY USE ONCE!
echo '<input type="hidden" name="sp_noncename" id="sp_noncename" value="' .
wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
// The actual fields for data entry
echo '<label for="_listing_price">' . __("Listing Price:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_listing_price" value="'.get_post_meta($post->ID, '_listing_price', true).'" /><br /><br />';
echo '<label for="_mls">' . __("MLS # (if any):", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_mls" value="'.get_post_meta($post->ID, '_mls', true).'" /><br /><br />';
echo '<label for="_address">' . __("Address:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_address" value="'.get_post_meta($post->ID, '_address', true).'" /><br /><br />';
echo '<label for="_city">' . __("City:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_city" value="'.get_post_meta($post->ID, '_city', true).'" /><br /><br />';
echo '<label for="_state">' . __("State:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_state" value="'.get_post_meta($post->ID, '_state', true).'" /><br /><br />';
echo '<label for="_zip_code">' . __("Zip Code:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_zip_code" value="'.get_post_meta($post->ID, '_zip_code', true).'" /><br /><br />';
}
function sp_inner_custom_box_2() {
global $post;
// The actual fields for data entry
echo '<label for="_square_feet">' . __("Square Feet:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_square_feet" value="'.get_post_meta($post->ID, '_square_feet', true).'" /><br /><br />';
echo '<label for="_bedrooms">' . __("Bedrooms:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_bedrooms" value="'.get_post_meta($post->ID, '_bedrooms', true).'" /><br /><br />';
echo '<label for="_bathrooms">' . __("Bathrooms:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_bathrooms" value="'.get_post_meta($post->ID, '_bathrooms', true).'" /><br /><br />';
echo '<label for="_basement">' . __("Basement (full, 1/2, finished, unfinished):", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_basement" value="'.get_post_meta($post->ID, '_basement', true).'" /><br /><br />';
echo '<label for="_addtional_features">' . __("Additional Features:", 'sp' ) . '</label><br />';
echo '<textarea style="width: 95%;height: 100px;" name="_additional_features">' . get_post_meta($post->ID, '_additional_features', true) . '</textarea><br /><br />';
}
function sp_inner_custom_box_3() {
global $post;
// The actual fields for data entry
echo '<label for="_photo_1_large">' . __("Photo #1 URL:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_photo_1_large" value="'.get_post_meta($post->ID, '_photo_1_large', true).'" /><br /><br />';
echo '<label for="_photo_2_large">' . __("Photo #2 URL:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_photo_2_large" value="'.get_post_meta($post->ID, '_photo_2_large', true).'" /><br /><br />';
echo '<label for="_photo_3_large">' . __("Photo #3 URL:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_photo_3_large" value="'.get_post_meta($post->ID, '_photo_3_large', true).'" /><br /><br />';
echo '<label for="_photo_4_large">' . __("Photo #4 URL:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_photo_4_large" value="'.get_post_meta($post->ID, '_photo_4_large', true).'" /><br /><br />';
echo '<label for="_photo_5_large">' . __("Photo #5 URL:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_photo_5_large" value="'.get_post_meta($post->ID, '_photo_5_large', true).'" /><br /><br />';
echo '<label for="_photo_6_large">' . __("Photo #6 URL:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_photo_6_large" value="'.get_post_meta($post->ID, '_photo_6_large', true).'" /><br /><br />';
echo '<label for="_photo_7_large">' . __("Photo #7 URL:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_photo_7_large" value="'.get_post_meta($post->ID, '_photo_7_large', true).'" /><br /><br />';
echo '<label for="_photo_8_large">' . __("Photo #8 URL:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_photo_8_large" value="'.get_post_meta($post->ID, '_photo_8_large', true).'" /><br /><br />';
echo '<label for="_photo_9_large">' . __("Photo #9 URL:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_photo_9_large" value="'.get_post_meta($post->ID, '_photo_9_large', true).'" /><br /><br />';
echo '<label for="_photo_10_large">' . __("Photo #10 URL:", 'sp' ) . '</label><br />';
echo '<input style="width: 95%;" type="text" name="_photo_10_large" value="'.get_post_meta($post->ID, '_photo_10_large', true).'" /><br /><br />';
}
/* When the post is saved, saves our custom data */
function sp_save_postdata($post_id, $post) {
// verify this came from the our screen and with proper authorization,
// because save_post can be triggered at other times
if ( !wp_verify_nonce( $_POST['sp_noncename'], plugin_basename(__FILE__) )) {
return $post->ID;
}
// Is the user allowed to edit the post or page?
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post->ID ))
return $post->ID;
} else {
if ( !current_user_can( 'edit_post', $post->ID ))
return $post->ID;
}
// OK, we're authenticated: we need to find and save the data
// We'll put it into an array to make it easier to loop though.
$mydata['_listing_price'] = $_POST['_listing_price'];
$mydata['_mls'] = $_POST['_mls'];
$mydata['_address'] = $_POST['_address'];
$mydata['_city'] = $_POST['_city'];
$mydata['_state'] = $_POST['_state'];
$mydata['_zip_code'] = $_POST['_zip_code'];
$mydata['_square_feet'] = $_POST['_square_feet'];
$mydata['_bedrooms'] = $_POST['_bedrooms'];
$mydata['_bathrooms'] = $_POST['_bathrooms'];
$mydata['_basement'] = $_POST['_basement'];
$mydata['_additional_features'] = $_POST['_additional_features'];
$mydata['_photo_1_large'] = $_POST['_photo_1_large'];
$mydata['_photo_2_large'] = $_POST['_photo_2_large'];
$mydata['_photo_3_large'] = $_POST['_photo_3_large'];
$mydata['_photo_4_large'] = $_POST['_photo_4_large'];
$mydata['_photo_5_large'] = $_POST['_photo_5_large'];
$mydata['_photo_6_large'] = $_POST['_photo_6_large'];
$mydata['_photo_7_large'] = $_POST['_photo_7_large'];
$mydata['_photo_8_large'] = $_POST['_photo_8_large'];
$mydata['_photo_9_large'] = $_POST['_photo_9_large'];
$mydata['_photo_10_large'] = $_POST['_photo_10_large'];
// Add values of $mydata as custom fields
foreach ($mydata as $key => $value) { //Let's cycle through the $mydata array!
if( $post->post_type == 'revision' ) return; //don't store custom data twice
$value = implode(',', (array)$value); //if $value is an array, make it a CSV (unlikely)
if(get_post_meta($post->ID, $key, FALSE)) { //if the custom field already has a value
update_post_meta($post->ID, $key, $value);
} else { //if the custom field doesn't have a value
add_post_meta($post->ID, $key, $value);
}
if(!$value) delete_post_meta($post->ID, $key); //delete if blank
}
}
/* Use the admin_menu action to define the custom boxes */
add_action('admin_menu', 'sp_add_custom_box');
/* Use the save_post action to do something with the data entered */
add_action('save_post', 'sp_save_postdata', 1, 2); // save the custom fields
?>
|
|
#6
|
|||
|
|||
|
How have you added write-panel.php to your install? Have you loaded it as a plugin, or is it in the theme's tools folder?
If the latter, you need to add this to your functions.php: PHP Code:
__________________
Ade Themessence - Studiograsshopper WordPress plugins: Dynamic Content Gallery | Reveal Page Templates | Custom Taxonomies Menu Widget Check out the Genesis and Child Theme tutorials before posting your question - and please provide YOUR URL! Make Andrea happy - read her Firebug tutorial and save yourself loads of time and effort. |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I connect my MySQL Listing Database to LISTING.PHP? | idxstudios | General Discussion | 1 | 09-25-2009 04:23 PM |
| Add comments to listing page | AliKK | General Discussion | 1 | 09-11-2009 11:12 PM |
© Copyright 2012 Copyblogger Media LLC · StudioPress™ is a trademark of Copyblogger Media LLC
Privacy Policy | Refund Policy | Terms of Service | Affiliate Program | Contact Us