Skip to content

Commit

Permalink
Update: Archive and category PHP templates, no sidebar for monsters
Browse files Browse the repository at this point in the history
  • Loading branch information
laras126 committed Nov 10, 2018
1 parent dae6299 commit 9e7e0c4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
43 changes: 22 additions & 21 deletions archive.php
Expand Up @@ -14,29 +14,30 @@
* @since Timber 0.2
*/

$templates = array('archive.twig', 'index.twig');
$templates = array('archive.twig', 'index.twig');

$data = Timber::get_context();
$data = Timber::get_context();

$data['title'] = 'Archive';
$data['title'] = 'Archive';

if (is_day()){
$data['title'] = 'Archive: '.get_the_date( 'D M Y' );
} else if (is_month()){
$data['title'] = 'Archive: '.get_the_date( 'M Y' );
} else if (is_year()){
$data['title'] = 'Archive: '.get_the_date( 'Y' );
} else if (is_tag()){
$data['title'] = 'Tagged: ' . single_tag_title('', false);
} else if (is_category()){
$data['title'] = 'Category: ' .single_cat_title('', false);
array_unshift($templates, 'archive-'.get_query_var('cat').'.twig');
} else if (is_post_type_archive()){
$data['title'] = post_type_archive_title('', false);
array_unshift($templates, 'archive-'.get_post_type().'.twig');
}
if (is_day()){
$data['title'] = 'Day: ' . get_the_date( 'D M Y' );
} else if (is_month()){
$data['title'] = 'Month: ' . get_the_date( 'M Y' );
} else if (is_year()){
$data['title'] = 'Year: ' . get_the_date( 'Y' );
} else if (is_tag()){
$data['title'] = 'Tagged: ' . single_tag_title('', false);
} else if (is_category()){
$data['title'] = 'Category: ' . single_cat_title('', false);
array_unshift($templates, 'category-'.get_query_var('cat').'.twig');
} else if (is_post_type_archive()){
$data['title'] = post_type_archive_title('', false);
array_unshift($templates, 'archive-'.get_post_type().'.twig');
}

$data['posts'] = Timber::get_posts();
$data['sidebar'] = Timber::get_sidebar('sidebar.php');
$data['posts'] = new Timber\PostQuery();
$data['pagination'] = Timber::get_pagination();
$data['sidebar'] = Timber::get_sidebar('sidebar.php');

Timber::render($templates, $data);
Timber::render($templates, $data);
17 changes: 10 additions & 7 deletions category.php
Expand Up @@ -14,14 +14,17 @@
* @since Timber 0.2
*/

$templates = array('archive.twig', 'index.twig');
$templates = array('archive.twig', 'index.twig');

$data = Timber::get_context();
$data = Timber::get_context();

$cat = new TimberTerm();
$data['category'] = $cat;
$data['title'] = $cat->name;
$data['posts'] = Timber::get_posts();
$cat = new TimberTerm();
$data['term'] = $cat;
$data['pagination'] = Timber::get_pagination();
$data['posts'] = Timber::get_posts();

Timber::render(array('category-' . $cat->name . '.twig', 'archive.twig', 'index.twig'), $data);
if ( $cat->name !== 'Monsters' ) {
$data['sidebar'] = Timber::get_sidebar('sidebar.php');
}

Timber::render(array('category-' . $cat->name . '.twig', 'archive.twig', 'index.twig'), $data);

0 comments on commit 9e7e0c4

Please sign in to comment.