Results 1 to 3 of 3

Thread: Full pages

  1. #1
    Thread Starter
    Member thewebsiteman's Avatar
    Join Date
    Jun 2009
    Posts
    50
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Full pages

    Okay so I can make full page posts using other themes I own.
    But what I'm hoping someone will post here is how to move the contact for,
    The Maps, and the Images area info below the post. (just like a regular Ad).

    This would be useful if you want a Full Page - will all the other information.

    This may be in the wrong section of this forum [ move as needed ].

    First.
    I have a New fullpost.php template included in the ROOT WPClassiPress Folder, as such:
    Code:
    <?php
    /*
    Single Post Template: Full Width Posts
    */
    ?>
    <?php
    /*
    Template Name: Full
    */
    ?>
    
    <?php get_header(); ?>
    
    <center><div class="main ins">
    		
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>	
    	
    			<div class="left">
    			
    				<div class="title">
    					<h2><?php the_title(); ?></h2>
    					<div class="clear"></div>
    				</div>
    				
    				<div class="product">
    					<?php the_content(__('Read more &raquo;','cp')); ?>
    					<?php edit_post_link(__('Edit Page','cp'), '
    
    ', '</p>'); ?>
    				</div>
    				
    			</div>
    			
    		<?php endwhile; endif; ?>	
                
                
    
    <?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
                
            </div>
    		
    	</div>
    			
    </div></center>
    
    
    
    <?php get_footer(); ?>
    Next I have;
    Second Step: You need post_templates.php, in a sub-directory called "tools" in your theme directory.

    Here's the post_templates.php code:
    Code:
    <?php
    /*
    Plugin Name: WordPress Post Templates
    Plugin URI: http://www.nathanrice.net/post-templates-plugin
    Description: This plugin allows theme authors to include single post templates, much like a theme author can use page template files.
    Version: 1.0
    Author: Nathan Rice
    Author URI: http://www.nathanrice.net/
    
    License: This plugin is licensed under GPL.  
    */
    
    //This function scans the template files of the active theme, 
    //and returns an array of [Template Name => {file}.php]
    if(!function_exists('get_post_templates')) {
    function get_post_templates() {
    	$themes = get_themes(); //an array of all themes in the /themes directory
    	$theme = get_current_theme(); //the current, active theme
    	$templates = $themes[$theme]['Template Files']; //a list of all the current theme's template files
    	$page_templates = array ();
    
    	foreach ((array)$templates as $template ) { //this loop returns all the "post templates"
    		$template_data = implode( '', file( WP_CONTENT_DIR.$template ));
    		$name = '';
    		if ( preg_match( '|Single Post Template:(.*)$|mi', $template_data, $name ) ) { $name = $name[1]; }
    		if ( !empty( $name ) ) { $post_templates[trim( $name )] = basename( $template ); }
    	}
    	return $post_templates; //return the array of Post Templates
    }}
    
    //build the dropdown items
    function page_templates_dropdown() {
    	global $post;
    	$post_templates = get_post_templates();
    	
    	foreach ($post_templates as $template_name => $template_file) { //loop through templates, make them options
    		if ($template_file == get_post_meta($post->ID, '_wp_post_template', true)) { $selected = ' selected="selected"'; } else { $selected = ''; }
    		$opt = '<option value="' . $template_file . '"' . $selected . '>' . $template_name . '</option>';
    		echo $opt;
    	}
    }
    
    //Filter the single template value, and replace it with
    //the template chosen by the user, if they chose one.
    add_filter('single_template', 'get_post_template');
    if(!function_exists('get_post_template')) {
    function get_post_template($template) {
    	global $post;
    	$custom_field = get_post_meta($post->ID, '_wp_post_template', true);
    	if(!empty($custom_field) && file_exists(TEMPLATEPATH . "/{$custom_field}")) { 
    		$template = TEMPLATEPATH . "/{$custom_field}"; }
    	return $template;
    }}
    
    //Everything below this is for adding the extra box
    //to the post edit screen so the user can choose a template
    
    //Adds a custom section to the Post edit screen
    add_action('admin_menu', 'pt_add_custom_box');
    function pt_add_custom_box() {
    	if(get_post_templates() && function_exists( 'add_meta_box' )) {
    		add_meta_box( 'pt_post_templates', __( 'Single Post Template', 'pt' ), 
    			'pt_inner_custom_box', 'post', 'normal', 'high' ); //add the boxes under the post
    	}
    }
       
    //Prints the inner fields for the custom post/page section
    function pt_inner_custom_box() {
    	global $post;
    	// Use nonce for verification
    	echo '<input type="hidden" name="pt_noncename" id="pt_noncename" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
    	// The actual fields for data entry
    	echo '<select name="_wp_post_template" id="_wp_post_template" class="dropdown">';
    	echo '<option value="">Blog Post</option>';
    	page_templates_dropdown(); //get the options
    	echo '</select>
    
    ';
    	echo '<label for="_wp_post_template">' . __("Choose to either publish your post as a blog post or property listing.", 'pt' ) . '</label>
    ';
    }
    
    //When the post is saved, saves our custom data
    add_action('save_post', 'pt_save_postdata', 1, 2); // save the custom fields
    function pt_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['pt_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 the data into an array to make it easier to loop though and save
    	$mydata['_wp_post_template'] = $_POST['_wp_post_template'];
    	// 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); //...then just update the data
    		} else { //if the custom field doesn't have a value...
    			add_post_meta($post->ID, $key, $value);//...then add the data
    		}
    		if(!$value) delete_post_meta($post->ID, $key); //and delete if blank
    	}
    }
    ?>
    Third Step: Then you need to Add this to your existing functions.php:
    Code:
    <?php
    /*
    Single Post Template: Full Width Posts
    */
    ?>
    OKAY Fine, Now you now have a FULL POST area, no sidebar - but No MAPS, No Images, just an area where you can change the listing (thumbnails show up for the main index page listings....).

    I have a working example in my playground here:
    http://www.buy-sell-local.com/playgr...sale-by-agent/
    and here using Ta table created with GoLive then copied the code for the Post:
    http://www.buy-sell-local.com/playgr...erms-of-usage/

    this still needs lots of work.

    But maybe someone will come along and correct me in my methods of insanity.

  2. #2
    Thread Starter
    Member thewebsiteman's Avatar
    Join Date
    Jun 2009
    Posts
    50
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Full pages

    Of course as you may see, I' getting some king of an error currently.

    if you double click on the text: the whole page gets Greyed out.

    Hmmmm

    Going to have to re-think this a bit more.


  3. #3
    Amateur classic's Avatar
    Join Date
    Oct 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Full pages

    Quote Originally Posted by TheWebsiteMan
    Of course as you may see, I' getting some king of an error currently.

    if you double click on the text: the whole page gets Greyed out.

    Hmmmm

    Going to have to re-think this a bit more.

    Nice job But try to seen on left hand top corner Did i just see 9 ??

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. adding pay pal to the advertisement pages
    By birdy in forum ClassiPress General Discussion
    Replies: 4
    Last Post: July 20th, 2009, 02:23 PM