Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMichael O'Kane
5,896 Pointstwig file final render
hi
i've been having a bit of trouble with the about.twig file rendering
it doesn't seem to be picking up the HTML or the CSS and it is rendering out only the content.
About.twig
{% extends 'main.twig' %}
{% block content %}
<strong>About</strong>
<h2>Ralph Waldo Emerson</h2>
<p>Ralph Waldo Emerson <em>(May 25, 1803 – April 27, 1882)</em> was an American essayist, lecturer, and poet, who led the Transcendentalist movement of the mid-19th century. He was seen as a champion of individualism and a prescient critic of the countervailing pressures of society, and he disseminated his thoughts through dozens of published essays and more than 1,500 public lectures across the United States.</p>
<p>Emerson gradually moved away from the religious and social beliefs of his contemporaries, formulating and expressing the philosophy of Transcendentalism in his 1836 essay, Nature. Following this ground-breaking work, he gave a speech entitled "The American Scholar" in 1837, which Oliver Wendell Holmes, Sr. considered to be America's "Intellectual Declaration of Independence".</p>
<p>Emerson wrote most of his important essays as lectures first, then revised them for print. His first two collections of essays – Essays: First Series and Essays: Second Series, published respectively in 1841 and 1844 – represent the core of his thinking, and include such well-known essays as Self-Reliance, The Over-Soul, Circles, The Poet and Experience. Together with Nature, these essays made the decade from the mid-1830s to the mid-1840s Emerson's most fertile period.</p>
<p>Emerson wrote on a number of subjects, never espousing fixed philosophical tenets, but developing certain ideas such as individuality, freedom, the ability for humankind to realize almost anything, and the relationship between the soul and the surrounding world. Emerson's "nature" was more philosophical than naturalistic: "Philosophically considered, the universe is composed of Nature and the Soul." Emerson is one of several figures who "took a more pantheist or pandeist approach by rejecting views of God as separate from the world.""
</p>
<p>He remains among the linchpins of the American romantic movement, and his work has greatly influenced the thinkers, writers and poets that have followed him. When asked to sum up his work, he said his central doctrine was "the infinitude of the private man." Emerson is also well known as a mentor and friend of fellow Transcendentalist Henry David Thoreau.</p>
<p><em>Learn more about Ralph Waldo Emerson from <a href="http://en.wikipedia.org/wiki/Ralph_Waldo_Emerson">Wikipedia</a></em></p>
{% endblock content %}
main.twig file
<!doctype html>
<html lang="en">
<head>
{% block head %}
<meta charset="utf-8">
<title>{% block title %}Ralph Waldo Emerson{% endblock title %}</title>
<meta name="description" content="Ralph Waldo Emerson">
<meta name="author" content="Treehouse">
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/master.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="js/global.js"></script>
{% endblock head %}
</head>
<body>
<!--
<div id="feedback" class="success">
<h3>Success!</h3>
<p>You're reading all about Emerson.</p>
</div>
-->
<header>
<h1>Ralph Waldo Emerson</h1>
<nav>
<a href="index.html" class="selected">About</a>
<a href="contact.html">Contact</a>
</nav>
</header>
<div class="emerson">
{% block hero %}<img src="images/emerson.jpg" alt="Picture of Ralph Waldo Emerson">{% endblock hero %}
</div>
<main>
{% block content %}
{% endblock content %}
</main>
<footer>
{% block footer %}
<p>A project from <strong><a href="http://teamtreehouse.com">Treehouse</a></strong></p>
<nav>
<a href="index.html" class="selected">About</a>
<a href="contact.html">Contact</a>
</nav>
{% endblock footer %}
</footer>
</body>
</html>
any help would be appreciated.
p.s i've never posted a question here before so hopefully this seems logical.
Michael
6 Answers
Ted Sumner
Courses Plus Student 17,967 PointsI need to see your index.php to see if this will actually solve your problems, but what is happening is your links are breaking because the about.twig is not in the same place as the paths suggest. This is the end code for portions of the main.twig:
<nav>
<a href="{{ baseUrl()}}" class="selected">About</a>
<a href="{{ siteUrl('/contact') }}">Contact</a>
</nav>
The link to your master.css file looks like mine does, so I would check to make sure the names are exactly the same, including case. The final project looks like this.
Michael O'Kane
5,896 PointsHi there
I spent some time today and basically when through the last video and it didn't seem to resolve the issue.
This is my full index.php file. Appreciate the help.
<?php
require 'vendor/autoload.php';
date_default_timezone_set('Europe/Belfast');
//$log = new Logger('name');
//$log->pushHandler(new StreamHandler('app.txt', Logger::WARNING));
//$log->addWarning('Oh Noes');
$app = new \Slim\Slim( array(
'view' => new \Slim\Views\Twig()
));
$view = $app->view();
$view->parserOptions = array(
'debug' => true
);
$view->parserExtensions = array(
new \Slim\Views\TwigExtension(),
);
$app->get('/', function() use($app){
$app->render('about.twig');
});
$app->get('/contact', function() use($app){
$app->render('contact.html');
});
$app->run();
Ted Sumner
Courses Plus Student 17,967 PointsEdited to add language after first three '`.
Ted Sumner
Courses Plus Student 17,967 PointsIf this project is in Workspaces, please make post a snapshot. You do that by clicking on the icon in the upper right side and following the steps until you can copy the URL. Paste that URL here.
Ted Sumner
Courses Plus Student 17,967 PointsYour main.twig does not contain the baseUrl() and siteUrl() code that is in my comment above. Have you added that to see if it fixes your problem?
Ted Sumner
Courses Plus Student 17,967 PointsOne issue I had on my system is that I did not change the nav in the contact.html file. You have to change the index.html to index.php if you have not made contact a twig file and used it with main.twig.
Michael O'Kane
5,896 PointsHi there,
Thanks for the help i managed to get it working. I went through the video again and realised the error of my ways. during the twig installation I think i may have selected the wrong package.
I also add the URL's as you suggested and it appears to be working now
also thanks for the help with snapshot
Michael
Ted Sumner
Courses Plus Student 17,967 PointsI am glad you got it figured out.
Ted Sumner
Courses Plus Student 17,967 PointsTed Sumner
Courses Plus Student 17,967 PointsEdited to format code.