Closed maietta closed 3 years ago
As explained in the Templates within templates section, you need to use
<include href="{{ @content }}" />
in order to include external templates. Otherwise, you're just echoing a string.
Heck yeah, that was the fix! Thank you so much! I had understood this "include" tag to only reference real files, not files set in the hive. Awesome. I'll close the issue with this response.
For anyone else not understanding, I simply changed
<main class="main container">{{ @content }}</main>
to
<main class="main container"><include href="{{ @content }}" /></main>
F3 Views & Templates
Quoted from the page: A practical use for such template directive is when you have several pages with a common HTML layout but with different content. Instructing the framework to insert a sub-template into your main template is as simple as writing the following PHP code:
// switch content to your blog sub-template $f3->set('content','blog.htm'); // in another route, switch content to the wiki sub-template $f3->set('content','wiki.htm');
A sub-template may in turn contain any number of directives. F3 allows unlimited nested templates.I have been unable to find a way to make this work and found no working examples anywhere online or from 3rd party community project examples
Assuming blog.htm or wiki.htm really does exist in in a directory set with the UI path setting like so: $fw->set("UI", "ui/");, I am still unable to trigger this to be displayed from within my main template.
My route looks like this:
$fw->route("GET /books/", function(\Base $fw){ $fw->set("page_title", "Puzzle Books"); $fw->set('content', 'books.htm'); echo \Template::instance()->render('full-width.htm'); });
My full-width template has some HTML that looks like:
<main class="main container">{{ @content }}</main>
All I am able to get in my template is "books.htm" instead of the actual rendered content.
I'm completely stumped and could use some help with this one. Thanks!