samuellittley
- Posts: 41
- Topic Created: Tue Jan 3 19:02:34 2012 +0100
I'm running a site that needs to be more pages based than blog based, as this site is. I'd like to create a page that is editable from the admin interface, which is what immediately appears at the root domain.
This site has a "home.twig" file in the theme pages directory, which is the homepage we see, having added one to my site, nothing happens, i still get the list of blog posts. My first question is how to change which page twig appears automatically.
My second is how I would retrieve a page inside a twig, rather than having to edit the twig files?
Admittedly, the first question is moot, because I can just do what needs to be done in the index twig, but I'd still like to know how it's done
samuellittley
Okay, just for reference, if you put the contents of index.twig into say blog.twig, in includes/controller/main.php you'll have to copy the method index, rename it to blog and replace any reference to index in it with blog.
There is probably another (better) way to do this, but never mind
samuellittley
And to retrieve a page inside twig, you have to copy page.twig to the name where you want to find the page (say index.twig for the front page) and in controller/Main.php, add a function named the same as the new twig i.e. index()
$page = new Page("<slug of page to display>");
if ($page->no_results)
return false; # Page not found; the 404 handling is handled externally.
$this->display(array("pages/<name of twig>", "pages/".$page->url), array("page" => $page), $page->title);