• Resolved mpmchugh

    (@mpmchugh)


    So, I notice that in the admin, when you View Staff Member you get a page displayed using single.php.

    Is there a way to set a template instead? (like :single-{posttype}.php)

    What is the Staff Member post-type?

    If so, are there template tags to pull in the other data fields? By default it only shows the image and the title. Can this be done with standard post-type template tags?

    I’m trying to figure out a way of using Easy Fanybox’s iframe ability to show the Staff Member’s page when their image is clicked. (we’re already using Easy Fancybox for a few other things).

    I guess I’d also need a [staff-page-url] tag too somehow, then.

    I was thinking of using Easy Fancybox’s ability to show inline content instead, but it requires each hidden div to be shown to have a different ID, though I guess I could use the [staff-name-slug] for the div ID.

    Just thought of that, but I’m curious if the iframe method described above would also work somehow with a custom template.

    Thanks,
    Michael

    https://www.ads-software.com/extend/plugins/simple-staff-list/

Viewing 13 replies - 16 through 28 (of 28 total)
  • Thread Starter mpmchugh

    (@mpmchugh)

    I just tested it in an install of mine, and it worked as is.

    There was no need to remove the “t_”s at all. Perhaps you deleted something else?

    Try using it as is.

    Thank you again Michael. It does not give any more error messages. However, I am very reluctant to ask and being holding it all day. Anyway, shedding my fear and pride ??

    I still don’t know how to incorporate this code with the staff page. I already have a list of staff members and I want each to open in a single page. So, my challenge now is to use this single page with what I already have.

    Thank you and sorry for the trouble.

    Thread Starter mpmchugh

    (@mpmchugh)

    The links in your staff page should work using something like this URL format:

    <a href="https://yoursite.com/staff-members/[staff-name-slug]>[staff-name-formatted]</a>

    -Michael

    Great! Worked now. I really appreciate your kindness. Have a good evening.

    This whole thread was incredibly helpful. Thanks to all of you!

    I came up with this simple class to simplify my single-staff-member.php. Maybe it’s useful for somebody else too.

    class StaffMember {
    	protected $record;
    	protected $record_prefix = '_staff_member_';
    	protected $class_prefix = 'staff-member-';
    
    	public function __construct() {
    		$this->record = get_post_custom();
    	}
    
    	public function __get( $field ) {
    		return $this->record[ $this->record_prefix . $field ][0];
    	}
    
    	public function show( $field, $markup = null, $class = null ) {
    		$content = $this->record[ $this->record_prefix . $field ][0];
    
    		if ( !$content ) return;
    		if ( !$markup ) $markup = 'span';
    		if ( !$class ) $class = $this->class_prefix . $field;
    
    		echo '<' . $markup . ' class="' . $class . '">' . $content . '</' . $markup . '>';
    	}
    
    	public function mailto( $class = null ) {
    		if ( !$class ) $class = $this->class_prefix . 'email';
    		echo '<a href="' . antispambot( $this->email ) . '" class="' . $class . '">' .
    			antispambot( $this->email ) . '</a>';
    	}
    }

    Nice and thanks for your efforts. Can you explain how you used it. My website was crashing with the one I copied from here and I had to remove it. I will appreciate your assistance.

    Sorry, I forgot to check e-mail notification. I think the crash may be related to the class name. I tend to prefix all my classes and variables, but removed the prefix before I posted the code, so there’s likely a namespace conflict. Try renaming the class to MyStaffMember or whatever suits you.

    The class is intended to be used to retrieve information about a single staff member for use in the single-staff-member.php, it will not work in other contexts.

    What it does is that it allows you to access the data about your staff member (e.g., phone number, email etc.) via class properties, so rather than saying, e.g.:

    $custom 	= get_post_custom();
    $title 		= $custom["_staff_member_title"][0];

    You can say:

    $member = new SomePrefix__StaffMember();
    $title = $member->title;

    Of course, the great thing is that there is no longer a need to define a variable for each field.

    There are also some convienience functions, namely, show() and mailto():

    show() will print the requested field, inside a <span> tag (or another tag which you can specify as 2nd argument), assigning a DOM (not PHP) class of the form “staff-member-$FIELD” where $FIELD is replaced with the name of the field printed (you can pass a third argument to show() to assign a different DOM class name).

    mailto() will simply print out a mailto link with the email address “encrypted” by WordPress’ antispambot() function. If you access the email address via show() or the email property of the StaffMember class, it will not be “encrypted”.

    So to give you an example, this is how my single-staff-member.php looks like (note the prefixes).

    <?php
    /**
     * The Template for displaying staff members
     *
     * See https://www.ads-software.com/support/topic/link-to-staff-member-page
     */
    
    $rockingthevorstand__single_staff_member_obj = new rockingthevorstand__StaffMember();
    
    get_header(); ?>
    	<div id="primary" class="site-content">
    		<div id="content" role="main">
    			<article class="staff-member staff-member-single type-staff-member">
    				<header class="entry-header staff-member-header">
    					<h1 class="entry-title"><?php echo get_the_title(); ?></h1>
    					<?php $rockingthevorstand__single_staff_member_obj->show( "title", "div" ); ?>
    				</header>
    				<div class="entry-content">
    					<?php if(has_post_thumbnail()): ?>
    						<div class="staff-member-photo">
    							<img class="staff-member-photo" height="180" width="150"
    								src="<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>"
    								alt="<?php echo get_the_title(); ?>" />
    						</div>
    					<?php endif; ?>
    					<div class="staff-member-content">
    						<?php if($rockingthevorstand__single_staff_member_obj->email) :?>
    							<div class="staff-member-email"><strong>E-Mail:</strong>
    								<?php $rockingthevorstand__single_staff_member_obj->mailto(); ?>
    							</div>
    						<?php endif; ?>
    						<?php $rockingthevorstand__single_staff_member_obj->show( "bio", "div" ); ?>
    					</div>
    				</div>
    			</article>
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    I’ve done all the above and still can’t get this to work. I have a single-staff-member.php in my theme folder and my (page-templates folder). Slug and everything works fine. Just when I click the read more button everything messes up.

    Please Help

    https://giveching.com/dev/about-us/

    Same with me but just switched to paid plugin. I did all as directed but never worked but luckily I found a pretty low cost plugin

    Dude, at this point I don’t care if it cost money. Post up the link where you got your paid plugin.

    Thread Starter mpmchugh

    (@mpmchugh)

    @ jbrew30 looks like your dev Team page is working. Did you figure it out?

    I just wanted to chime in that I read and re-read this thread several times, and gathered some additional information, and was able to get this working per the instructions. So THANK YOU! Great plugin.

    To (try to) clarify, for the less WP savvy and other newbies out there (like me), here is what I did. My goal was to have a single page with staff photos/name/positions and be able to click on the name to go to a single bio page for each person.

    1. Created a single-staff-member.php file in my theme folder, by duplicating single.php and dumping in the code that AJ refers to from https://www.ads-software.com/support/topic/custom-post-template-for-single-staff-member. I did need to modify this .php file to incorporate some of the divs from my theme’s single.php, so the page would look consistent with other pages.
    2. Modified the Staff Loop template (in WordPress) to include the link to the slug-name so that both the name and photo were linked:

    [staff_loop]
    <div class="staff-member-container">
    <a href="https://mywebsite.com/staff-members/[staff-name-slug]"> [staff-name-formatted]
    <img class="staff-member-photo" src="[staff-photo-url]" alt="[staff-name] : [staff-position]"></a>
     <div class="staff-member-info-wrap">
     [staff-position-formatted]
     </div>
     </div>
    [/staff_loop]
    <div style="clear:both;"></div>

    3.Modified the Staff Page CSS (in WordPress) per so that the staff listing page would be multi-columned:

    div.main_inner {
      display: table;
    }
    
    div.staff-member {
    float:left;/*fix for buggy browsers*/
    display:table-column;
    width:230px;
    height:250px;
    text-align: center;
    vertical-align: middle;
    }

Viewing 13 replies - 16 through 28 (of 28 total)
  • The topic ‘link to Staff Member page’ is closed to new replies.