• Resolved nibetanco

    (@nibetanco)


    Hello, me again, is there a way to add other fields or information to show in the Teams block with the table layout? I would like to show the years of service right under the title of the person. Thank you

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Steven

    (@shazahm1hotmailcom)

    You could try editing the template file:

    You would have to be very careful in the edits made as it can easily break the functioning on the block in the Editor.

    Any change made will be lost during a plugin update. As WordPress simply replaces the old files with the new ones.

    You could try saving the changes as a template override file to preserve the edits:

    The template slug is block-team-table.

    I have never tested and do not know offhand if the template override file will be loaded. It should be.

    Also, any code changes in this file will not change or add controls to the Editor for the block. That is not easily accomplished because that requires setting up a development build environment.

    I hope I have helped, please let me know.

    Thread Starter nibetanco

    (@nibetanco)

    I was able to create the template override file and as an example I added a duplicate of the tittle. But then I can’t find how to calculate the years or work using the Anniversary Date.

    Plugin Author Steven

    (@shazahm1hotmailcom)

    This is a little tricky… I think this should work:

    $dateCollection = $entry->dates->filterBy( 'type', 'anniversary' )->getCollection( 1 );
    $entryDate      = $dateCollection->first();
    
    if ( $entryDate instanceof cnEntry_Date ) {
    
    	$date = $entryDate->getDate();
    
    	if ( $date instanceof DateTime ) {
    
    		$today     = new DateTime( current_time( 'mysql' ) );
    		$interval  = $today->diff( $date );
    		$formatted = $interval->format( '%y Year(s)' );
    	}
    }
    
    echo $formatted;

    I hope I have helped, please let me know.

    Thread Starter nibetanco

    (@nibetanco)

    That worked perfect, I would like to do the same for the Grid layout. Do you think that same code works? Also, the template slug would be block-team-grid? Thank you

    • This reply was modified 3 years, 2 months ago by nibetanco.
    Thread Starter nibetanco

    (@nibetanco)

    Thank you Steven, I found what I was looking for.

    Plugin Author Steven

    (@shazahm1hotmailcom)

    Great to hear you were able to dig up the info needed to alter the grid layout of the Team Block.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Team block add years of service’ is closed to new replies.