1
0
mirror of https://github.com/ascribe/wp-theme synced 2024-12-22 17:23:55 +01:00

refactor & simplify featured posts markup & styles

This commit is contained in:
Matthias Kretschmann 2016-03-10 14:01:12 +01:00
parent b66c5a4e02
commit 1ff581d67b
2 changed files with 50 additions and 32 deletions

View File

@ -111,3 +111,26 @@
} }
} }
} }
//
// Featured Blog Posts
//
.subtemplate--featured {
@media (@screen-sm) {
.grid__col { flex: 33%; }
}
}
.subtemplate--featured--more {
&:extend(.text-center);
margin-bottom: 0;
}
.featured {
}
.featured__title {
&:extend(.h4);
}

View File

@ -349,14 +349,20 @@ class Subtemplate {
return $result; return $result;
} }
public function blogFeatures($page = "home") {
//
// Subtemplate: Featured Blog Posts
//
public function blogFeatures() {
$blogFeatures = ''; $blogFeatures = '';
$subtemplateTitle = get_sub_field('section_title'); $subtemplateTitle = get_sub_field('section_title');
if (have_rows('blog_features','option')) { if (have_rows('blog_features','option')) {
while (have_rows('blog_features','option')) { while (have_rows('blog_features','option')) {
the_row(); the_row();
$title = get_sub_field('feature_title');
$feature = get_sub_field('post'); $feature = get_sub_field('post');
$postTitle = $feature->post_title; $postTitle = $feature->post_title;
$url = get_permalink($feature->ID); $url = get_permalink($feature->ID);
@ -364,43 +370,32 @@ class Subtemplate {
$date = date('F Y', strtotime($feature->post_date)); $date = date('F Y', strtotime($feature->post_date));
$image = wp_get_attachment_image_src(get_post_thumbnail_id($feature->ID),'blog-feature-crop')[0]; $image = wp_get_attachment_image_src(get_post_thumbnail_id($feature->ID),'blog-feature-crop')[0];
if ($page == "home") { $blogFeatures .= "<div class='grid__col'>
$blogFeatures .= "<a href='{$url}'><article class='blog'><div> <a href='{$url}'>
<img src='{$image}' alt='{$postTitle} Image'> <article class='featured'>
<h2>{$title}</h2> <img class='featured__image' src='{$image}' alt='{$postTitle} Image'>
<h1>{$postTitle}</h1></div> <h1 class='featured__title'>{$postTitle}</h1>
</article></a>"; </article>
</a>
} </div>";
else {
$blogFeatures .= "<a href='{$url}'><article class='blog'>
<h1>{$postTitle}</h1>
<time>{$date}</time>
<div>{$content}</div>
</article></a>";
}
} }
} }
if ($page == "home") { $result = "<section class='subtemplate row subtemplate--featured'>
$result = "<section class='subtemplate blog-features'>
<div class='row'>
<h1 class='subtemplate__title'>{$subtemplateTitle}</h1> <h1 class='subtemplate__title'>{$subtemplateTitle}</h1>
<div class='column-container'> <div class='grid grid--gutters grid--full grid-small--fit'>
{$blogFeatures} {$blogFeatures}
</div> </div>
</div> <p class='subtemplate--featured--more'><a class='button small white-blue' href=''>Go to Blog</a></p>
</section>"; </section>";
}
else {
$result = "<section class='sidebar-blog-features'>
{$blogFeatures}
</section>";
}
return $result; return $result;
} }
//
// Subtemplate: Team
//
public function team($subtemplateTitle) { public function team($subtemplateTitle) {
$content = get_sub_field('content'); $content = get_sub_field('content');
$meetTeamLink = get_sub_field('meet_the_team_link'); $meetTeamLink = get_sub_field('meet_the_team_link');