Skip to content

Commit

Permalink
Merge pull request #130 from MITLibraries/lm420
Browse files Browse the repository at this point in the history
Update Child theme to better support Interview / Interviewees content
  • Loading branch information
matt-bernhardt authored Jun 29, 2023
2 parents 01f2a98 + 423fcbe commit 61f9103
Show file tree
Hide file tree
Showing 8 changed files with 288 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public static function define() {
'labels' => $labels,
'description' => '',
'public' => true,
'publicly_queryable' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_rest' => false,
'rest_base' => '',
'rest_controller_class' => 'WP_REST_Posts_Controller',
'rest_namespace' => 'wp/v2',
'has_archive' => false,
'has_archive' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'delete_with_user' => false,
Expand All @@ -43,7 +43,7 @@ public static function define() {
'map_meta_cap' => true,
'hierarchical' => false,
'can_export' => true,
'rewrite' => true,
'rewrite' => array( 'slug' => 'interviewees' ),
'query_var' => true,
'supports' => array( 'title', 'editor', 'custom-fields', 'revisions', 'thumbnail' ),
'taxonomies' => array( 'category', 'post_tag' ),
Expand Down
114 changes: 114 additions & 0 deletions web/app/themes/mitlib-child/archive-interviewee.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php
/**
* The template for displaying the archive of all Interviewee records.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package MITlib_Child
* @since 1.0.2
*/

namespace Mitlib\Child;

$interviewee_params = array(
'posts_per_page' => -1,
'post_type' => 'interviewee',
'post_status' => 'publish',
'meta_key' => 'sort-name',
'orderby' => 'sort-name',
'order' => 'ASC',
);
$interviewees = new \WP_Query( $interviewee_params );

$interview_params = array(
'post_type' => 'interview',
'posts_per_page' => -1,
'orderby' => 'post_date',
'order' => 'ASC',
'post_status' => 'publish',
);
$interviews = new \WP_Query( $interview_params );
?>

<?php get_header( 'child' ); ?>

<?php get_template_part( 'inc/breadcrumbs', 'child' ); ?>

<div id="stage" class="inner" role="main">

<?php get_template_part( 'inc/title-banner' ); ?>

<div id="content" class="content">

<div class="content-main main-content">

<?php if ( $interviewees->have_posts() ) { ?>

<div class="entry-content">
<h1>Index of interviewees</h1>

<div class="table">
<div class="table-row table-head">
<div class="table-cell"><span>Photo</span></div>
<div class="table-cell"><span>Name</span></div>
<div class="table-cell"><span>MIT affiliation</span></div>
<div class="table-cell"><span>Music / professional work</span></div>
<div class="table-cell"><span>Interview dates</span></div>
</div>

<?php
while ( $interviewees->have_posts() ) {
$interviewees->the_post();
$record_id = get_the_ID();
$interviewee_name = get_the_title();
$affiliation = get_field( 'mit-affiliation' );
$work = get_field( 'music-professional-work' );
?>

<div class="table-row">
<div class="table-cell">
<?php
if ( has_post_thumbnail() ) {
echo '<span class="table-value-only">';
the_post_thumbnail( 'small' );
echo '</span>';
} else {
echo '<span class="table-value-only null-image">&nbsp;</span>';
}
?>
</div>
<div class="table-cell"><span class="table-value-only record-title"><strong><?php the_title(); ?></strong></span></div>
<div class="table-cell"><span class="table-label">MIT affiliation</span><span class="table-value"><?php echo esc_html( $affiliation ); ?></span></div>
<div class="table-cell"><span class="table-label">Music / professional work</span><span class="table-value"><?php echo esc_html( $work ); ?></span></div>
<div class="table-cell">
<span class="table-label">Interview dates</span>
<?php
if ( $interviews->have_posts() ) {
echo '<ul class="table-value">';
while ( $interviews->have_posts() ) {
$interviews->the_post();
$interview_title = get_the_title();
if ( str_contains( $interview_title, $interviewee_name ) ) {
echo '<li><a href="' . esc_url( get_permalink() ) . '">';
echo get_the_date( 'n/j/Y' );
echo '</a></li>';
}
};
echo '</ul>';
};
?>
</div>
</div>
<?php } ?>
</div> <!-- end div.table -->

</div> <!-- end div.entry-content -->

<?php } ?>
</div>

</div>

</div>

<?php get_footer(); ?>
108 changes: 108 additions & 0 deletions web/app/themes/mitlib-child/css/scss/interviewees.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
.table {
display: table;

.table-head {
font-weight: bold;
}

.table-row {
display: table-row;

.table-cell {
border-bottom: 1px solid #ddd;
display: table-cell;
vertical-align: top;

.table-label {
display: none;
}

img {
height: auto;
max-width: 100px;
width: 100px;
}

span {
display: block;
margin: 10px 20px 10px 10px;

&.null-image {
height: 100px;
}

&.record-title {
font-size: 18px;
}
}

ul {
margin: 10px 20px 10px 10px;

li {
margin: 0;
list-style: none;

&:before {
content: "";
font-family: FontAwesome;
color: #338bc5;
font-size: 12px;
margin-left: -12px;
}
}
}
}

&:nth-child(even) {
background-color: #f2f2f2;
}
}
}


@media (max-width: 768px) {
.table {
display: block;

.table-head {
display: none;
}

.table-row {
border-bottom: 1px solid #676767;
display: block;
padding: 15px 0;

.table-cell {
border-bottom: none;
display: flex;

.table-label {
display: block;
font-weight: bold;
width: 33%;
}


.table-value {
width: 66%;
}

.table-value-only {
margin-left: 33%;
padding-left: 20px;
width: 66%;
}

ul li:before {
margin-left: 0;
}
}

&.table-head {
display: none;
}
}
}
}
20 changes: 19 additions & 1 deletion web/app/themes/mitlib-child/css/scss/interviews.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,30 @@
#titlebar {
background: #f2f0f0;

.row-icon {
margin: 9px 9px 6px 9px;
}

.list-inline {
margin-top: 12px;
margin-bottom: 6px;
margin-top: 9px;

&.links li {
margin-right: 12px;
}

&.tags li,
&.categories li {
padding-left: 0;

&:after {
content: ' | ';
}

&:last-child:after {
content: '';
}
}
}

.post-thumbnail {
Expand Down
10 changes: 9 additions & 1 deletion web/app/themes/mitlib-child/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ function child_scripts_styles() {
wp_register_style( 'bootstrap', '//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css', array(), '3.0.0' );
wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css', array(), '4.6.0' );
wp_register_style( 'interviews', get_stylesheet_directory_uri() . '/css/build/interviews.css', array(), $theme_version );
wp_register_style( 'child-style', get_stylesheet_uri(), array( 'parent-global' ), $theme_version );
wp_register_style( 'interviewees', get_stylesheet_directory_uri() . '/css/build/interviewees.css', array(), $theme_version );
wp_register_style( 'child-style', get_stylesheet_uri(), array( 'parent-global', 'dashicons' ), $theme_version );

// Then we register javascript libraries.
wp_deregister_script( 'jquery' );
Expand All @@ -53,6 +54,11 @@ function child_scripts_styles() {
wp_enqueue_style( 'interviews' );
wp_enqueue_script( 'youtube-iframe-api' );
}

// Load the styles for the index of interviewees only on that archive.
if ( is_post_type_archive( 'interviewee' ) ) {
wp_enqueue_style( 'interviewees' );
}
}
add_action( 'wp_enqueue_scripts', 'Mitlib\Child\child_scripts_styles' );

Expand Down Expand Up @@ -111,6 +117,8 @@ function theme_setup() {
'uploads' => true,
);
add_theme_support( 'custom-header', $args );

add_image_size( 'small', 100, 100, true );
}
add_action( 'after_setup_theme', 'Mitlib\Child\theme_setup' );

Expand Down
Binary file removed web/app/themes/mitlib-child/images/no-photo.png
Binary file not shown.
Loading

0 comments on commit 61f9103

Please sign in to comment.