Skip to content

Commit

Permalink
fix: fix paths to twig files
Browse files Browse the repository at this point in the history
  • Loading branch information
Levdbas committed May 20, 2024
1 parent a8619fe commit 91fd930
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 36 deletions.
3 changes: 2 additions & 1 deletion 404.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* The template for displaying 404 pages (Not Found)
*
Expand All @@ -10,4 +11,4 @@
*/

$context = Timber::context();
Timber::render( '404.twig', $context );
Timber::render('templates/404.twig', $context);
33 changes: 17 additions & 16 deletions archive.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* The template for displaying Archive pages.
*
Expand All @@ -14,27 +15,27 @@
* @since Timber 0.2
*/

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

$context = Timber::context();

$context['title'] = 'Archive';
if ( is_day() ) {
$context['title'] = 'Archive: ' . get_the_date( 'D M Y' );
} elseif ( is_month() ) {
$context['title'] = 'Archive: ' . get_the_date( 'M Y' );
} elseif ( is_year() ) {
$context['title'] = 'Archive: ' . get_the_date( 'Y' );
} elseif ( is_tag() ) {
$context['title'] = single_tag_title( '', false );
} elseif ( is_category() ) {
$context['title'] = single_cat_title( '', false );
array_unshift( $templates, 'archive-' . get_query_var( 'cat' ) . '.twig' );
} elseif ( is_post_type_archive() ) {
$context['title'] = post_type_archive_title( '', false );
array_unshift( $templates, 'archive-' . get_post_type() . '.twig' );
if (is_day()) {
$context['title'] = 'Archive: ' . get_the_date('D M Y');
} elseif (is_month()) {
$context['title'] = 'Archive: ' . get_the_date('M Y');
} elseif (is_year()) {
$context['title'] = 'Archive: ' . get_the_date('Y');
} elseif (is_tag()) {
$context['title'] = single_tag_title('', false);
} elseif (is_category()) {
$context['title'] = single_cat_title('', false);
array_unshift($templates, 'templates/archive-' . get_query_var('cat') . '.twig');
} elseif (is_post_type_archive()) {
$context['title'] = post_type_archive_title('', false);
array_unshift($templates, 'templates/archive-' . get_post_type() . '.twig');
}

$context['posts'] = Timber::get_posts();

Timber::render( $templates, $context );
Timber::render($templates, $context);
2 changes: 1 addition & 1 deletion author.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
$context['author'] = $author;
$context['title'] = 'Author Archives: ' . $author->name();
}
Timber::render( array( 'author.twig', 'archive.twig' ), $context );
Timber::render( array( 'templates/author.twig', 'templates/archive.twig' ), $context );
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
$context = Timber::context();
$context['posts'] = Timber::get_posts();
$context['foo'] = 'bar';
$templates = array( 'index.twig' );
$templates = array( 'templates/index.twig' );
if ( is_home() ) {
array_unshift( $templates, 'front-page.twig', 'home.twig' );
array_unshift( $templates, 'templates/front-page.twig', 'templates/home.twig' );
}
Timber::render( $templates, $context );
2 changes: 1 addition & 1 deletion page.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@

$timber_post = Timber::get_post();
$context['post'] = $timber_post;
Timber::render( array( 'page-' . $timber_post->post_name . '.twig', 'page.twig' ), $context );
Timber::render(array('templates/page-' . $timber_post->post_name . '.twig', 'templates/page.twig'), $context);
2 changes: 1 addition & 1 deletion search.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @since Timber 0.1
*/

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

$context = Timber::context();
$context['title'] = 'Search results for ' . get_search_query();
Expand Down
7 changes: 4 additions & 3 deletions single.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* The Template for displaying all single posts
*
Expand All @@ -13,8 +14,8 @@
$timber_post = Timber::get_post();
$context['post'] = $timber_post;

if ( post_password_required( $timber_post->ID ) ) {
Timber::render( 'single-password.twig', $context );
if (post_password_required($timber_post->ID)) {
Timber::render('single-password.twig', $context);
} else {
Timber::render( array( 'single-' . $timber_post->ID . '.twig', 'single-' . $timber_post->post_type . '.twig', 'single-' . $timber_post->slug . '.twig', 'single.twig' ), $context );
Timber::render(array('templates/single-' . $timber_post->ID . '.twig', 'templates/single-' . $timber_post->post_type . '.twig', 'templates/single-' . $timber_post->slug . '.twig', 'templates/single.twig'), $context);
}
2 changes: 1 addition & 1 deletion views/partials/tease-post.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'tease.twig' %}
{% extends 'partials/tease.twig' %}

{% block content %}
<h2 class="h2"><a href="{{ post.link }}">{{ post.title }}</a></h2>
Expand Down
2 changes: 1 addition & 1 deletion views/partials/tease.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
<img src="{{ post.thumbnail.src }}" />
{% endif %}
{% endblock %}
</article>
</article>
2 changes: 1 addition & 1 deletion views/templates/404.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base.twig' %}
{% extends 'layouts/base.twig' %}

{% block content %}
Sorry, we couldn't find what you're looking for.
Expand Down
2 changes: 1 addition & 1 deletion views/templates/archive.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{# This file demonstrates using most of the index.twig template and modifying
just a small part. See `search.twig` for an example of another approach #}

{% extends 'index.twig' %}
{% extends 'templates/index.twig' %}

{% block content %}
<h3>This is my archive</h3>
Expand Down
2 changes: 1 addition & 1 deletion views/templates/author.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base.twig' %}
{% extends 'layouts/base.twig' %}

{% block content %}
{% for post in posts %}
Expand Down
2 changes: 1 addition & 1 deletion views/templates/index.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base.twig' %}
{% extends 'layouts/base.twig' %}

{% block content %}
<h2>{{ foo }}</h2>
Expand Down
2 changes: 1 addition & 1 deletion views/templates/page.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base.twig' %}
{% extends 'layouts/base.twig' %}

{% block content %}
<div class="content-wrapper">
Expand Down
4 changes: 2 additions & 2 deletions views/templates/search.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{# see `archive.twig` for an alternative strategy of extending templates #}
{% extends 'base.twig' %}
{# see `templates/archive.twig` for an alternative strategy of extending templates #}
{% extends 'layouts/base.twig' %}

{% block content %}
<div class="content-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion views/templates/single-password.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base.twig' %}
{% extends 'layouts/base.twig' %}

{% block content %}
<form class="password-form"
Expand Down
2 changes: 1 addition & 1 deletion views/templates/single.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base.twig' %}
{% extends 'layouts/base.twig' %}

{% block content %}
<div class="content-wrapper">
Expand Down

0 comments on commit 91fd930

Please sign in to comment.