Jump to content
Sign in to follow this  
tazzydemon

A solution for author.php

Recommended Posts

tazzydemon

For all of you who want an author.php I have now done it and it's surprisingly easy. I will upload files to my server as I cant upload them here. It took me a while to figure out how to do this and I have had to hook into a pretty low level Platform function - but entirely in the sub-theme Platformbase. Here's how (all in Platformbase): After you do the steps below go to the admin and select the author page in template setup. Drag the author section into it. Believe it or not you don't need a page type page such as page.author.php as this is handled by the function.php hook You will have to customise the section.author.php to suit your requirements. here is a file archive: http://www.bitstream.co.nz/platform/platformbase.zip - do not just copy over functions.php if you have modifed yours. Compare and merge them. 1. In functions.php add this line to function base_sections() pagelines_register_section('BaseAuthor','author', null, array('child' =>true)); 2. In functions.php add this line to the if statement if ( function_exists( 'pagelines_add_page' ) if ( function_exists( 'pagelines_add_page' ) ){ pagelines_add_page('base', 'Custom Page'); pagelines_add_page('author', 'Author Page'); // this line added 3. Add this at end of functions.php: ------------BEGIN CODE--------------- function get_base_main_type(){ if(is_author()){ return 'author'; }elseif(is_home() || is_tag() || is_search() || is_archive() || is_category()){ return 'posts'; }elseif(is_single()){ return 'single'; }elseif(is_404()){ return '404'; }else { return 'default'; } } function get_base_page_template(){ global $post; if(is_404()){ return '404';} elseif(is_author()){return 'author';} elseif(is_home() || is_tag() || is_search() || is_archive() || is_category()){ return 'posts';} elseif(is_single()){return 'single';} elseif(is_page_template()){ /* Strip the page. and .php from page.[template-name].php */ $page_filename = str_replace('.php', '', get_post_meta($post->ID,'_wp_page_template',true)); $template_name = str_replace('page.', '', $page_filename); return $template_name; }else{return 'default';} } function spoof_platform_author_detection(){ global $pagelines_template; $pagelines_template->template_type = get_base_page_template(); $pagelines_template->main_type = get_base_main_type(); $pagelines_template->map= $pagelines_template->get_map(); $pagelines_template->get_loaded_sections(); //print_r($pagelines_template); } add_action('pagelines_before_html', 'spoof_platform_author_detection',20); // Note the priority 20 to make sure it happens after the real hook function ------------END CODE--------------------------- 4. Create a template.author.php in the root of Platformbase and put this in it: ----------------BEGIN CODE ----------- <?php global $pagelines_layout; global $base_authorid; $base_authorid = get_query_var( 'author' ); //$curauth = (get_query_var('author')) ? get_user_by('slug', get_query_var('author')) : get_userdata(get_query_var('author')); $curauth = get_userdata($base_authorid); // included in theme root for easy editing. //include( TEMPLATEPATH.'/template.branding.php' ); //get_template_part( 'template.author'); global $pagelines_layout; global $post; ?>

<?php pagelines_register_hook( 'pagelines_content_before_columns', 'maincontent' ); // Hook ?>
<?php pagelines_register_hook( 'pagelines_content_before_maincolumn', 'maincontent' ); // Hook ?>
<?php //pagelines_template_area('pagelines_main', 'main'); ?>

About <?php echo $curauth->first_name.' '.$curauth->last_name?>

<?php $permalink = get_permalink($post->ID); if(strpos($permalink, '?')) $concat = '&'; else $concat = '?'; $display_gravatar = get_avatar($curauth->user_email, 96 ); if(function_exists('userphoto_the_author_photo')){ $photo = userphoto__get_userphoto($curauth->ID, USERPHOTO_THUMBNAIL_SIZE, "", "", array(), ""); if(!empty($photo)){ echo("
ID" title="$curauth->display_name">" . $photo . "
n"); } } elseif(get_avatar($curauth->user_email)){ echo("
ID" title="$curauth->display_name">$display_gravatar
n"); } ?>

Profile

<?php echo $curauth->user_description; ?>

Posts by <?php echo $curauth->first_name.' '.$curauth->last_name ?>:

  • <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  • <?php the_title(); ?>, <?php the_time('d M Y'); ?> in <?php the_category('&');?> <?php endwhile; else: ?>

<?php _e('No posts by this author.'); ?>

<?php endif; ?>
<?php if($pagelines_layout->layout_mode == 'two-sidebar-center'):?> <?php pagelines_register_hook( 'pagelines_content_before_sidebar1', 'maincontent' ); // Hook ?>
<?php pagelines_template_area('pagelines_sidebar1', 'sidebar1'); ?>
<?php pagelines_register_hook( 'pagelines_content_after_sidebar1', 'maincontent' ); // Hook ?> <?php endif;?>
<?php get_sidebar(); ?>
-------------END CODE----------- 5. Create an author directory in Platformbase/sections and create a section.author.php and author.css in it section.author.php: ------------BEGIN CODE ----------- <?php /* Section: Author Section Author: Julian Description: Shows author bio Version: 1.0.0 Demonstrates how to create a cool site section in 50 lines of code! Note: the only other piece to make this work is the 'pagelines_register_section()' function in your functions.php */ class BaseAuthor extends PageLinesSection { function __construct( $registered_settings = array() ) { // BASIC INFO /* The name and ID of the section */ $name = __('Author Section', 'pagelines'); $id = 'author'; // SETTINGS $settings = array( 'description' => 'Displays standard author bio using redirected author.php.', 'workswith' => array('templates'), 'failswith' => array('404'), 'icon' => PL_ADMIN_ICONS . '/document.png' ); parent::__construct($name, $id, $settings); } function section_template(){ get_template_part( 'template.author' ); } function section_styles(){ pagelines_load_css( get_stylesheet_directory_uri() . '/sections/author/author.css', 'author'); } } --------------END CODE----------- author.css ---------------BEGIN CODE ------------ #pagelines_author H2 { margin-bottom: 20px; } #author-photo, #author-profile, #author-website, #author-posts { margin: 10px 10px 10px 0; padding: 10px; border: 1px solid #E9E9E9; } #author-profile { } #author-website { } #author-posts UL { list-style-type: none; } ---------END CODE-------------

Share this post


Link to post
Share on other sites
Jenny
Can you please provide a working link so we can see what it looks like? Thanks!

Jenny :: Web designer at Simple Mama (follow me at @simplemamacom)

Check out Share Me, a social sharing add-on for DMS that is super simple to set up.

Share this post


Link to post
Share on other sites
tazzydemon
Its a work in progress and only my second WP site (I prefer Silverstripe).. but have a look at: http://www.stratus.ac.nz/author/tazzydemon Feel free to surf for more. Just noticed I still have morefoot in there. Will fix that Julian

Share this post


Link to post
Share on other sites
Rob
And for those of you patient enough to wait or who don't want to re-write that much code, the next version of PlatformPro will have author page capability built right in. At least according to informed sources.

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
tazzydemon
Nothing to rewrite.. its all in the Platformbase download I gave you!! Just remove it when the new one comes out!

Share this post


Link to post
Share on other sites
tazzydemon
I don't know which of the respondents here (if any) work for Pagelines, but I have been amused to observe that after a week of asking for the author feature and being diverted elsewhere (as others have) it took me hours of work to actually solve this problem to prompt an admission it was being done. Did I say amused?

Share this post


Link to post
Share on other sites
Jenny
That looks great! I don't use an author page on any of my blogs but if I did, I'd want something like that. :)

Jenny :: Web designer at Simple Mama (follow me at @simplemamacom)

Check out Share Me, a social sharing add-on for DMS that is super simple to set up.

Share this post


Link to post
Share on other sites
tazzydemon
Thanks Jenny. It was a specific requirement from this client and there may be quite a few contributors as you can imagine given the research flavour. You can imagine my horror that Platform didn't have it, given that it was a semi-standard pointed to inside the WP site. At least I have been forced to find out how the templates work though!! PS I also use the Members plugin for extra roles such as committee and a modified Wordpress Users plugin to just show committe members and their functions. The addition fields and additional registration fields were by PIE Register - and I have been posting the author of that a lot of feedback and corrections too - but he has credited me! Julian

Share this post


Link to post
Share on other sites
Jenny
That's great work! I look forward to seeing what else you can do in the future. :)

Jenny :: Web designer at Simple Mama (follow me at @simplemamacom)

Check out Share Me, a social sharing add-on for DMS that is super simple to set up.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×