You are not logged in.
So the portfolio site I'm building is one of those ones you see a lot these days where all of the content is displayed in large distinct sections all down the one single page - something like this site.
For ease of editing, I've set up the content in the backend using separate pages, some of which are tied to modules for things like case studies and portfolio items etc.
My problem is that while it's easy enough to spit out the content of each page by looping through the pages and using $cms->getPage(), that doesn't work for pages with different templates. I've set up templates to use for each type of content block, but I can't figure out how to render each of those templates and then provide that rendered content into the "master" template I'm using as the home page.
What I'd like to do is process the first part of the template rendering process (as described here), but only the first part, and then insert that into one of the content 'blocks' on the main page.
Is that possible? Am I barking up the wrong tree, and should I be looking into Callouts? I'm still a bit of a noob here and don't understand how the callouts system works so I may be missing something obvious.
I'd really appreciate any help or advice.
Thanks!
Offline
I'd say for ease of editing you're probably on the right track. If all of the pages you're combining into the master page are children of the master page I'd do something like this:
<?
$pages = $cms->getNavByParent($bigtree["page"]["id"],1);
foreach ($pages as $child) {
$page = $cms->getPage($child["id"]);
foreach ($page["resources"] as $key => $value) {
$$key = $value;
}
include "../templates/basic/".$page["template"].".php";
}
?>
The caveats there are that it can't be a routed template and you can't use "page" as an ID for any of your template resources that you're including or the template will fail to load.
If you want to actually load the template's content into a variable instead of outputting it you would do something like:
<?
ob_flush();
// Get page resources
// Include template file
$template_contents = ob_get_clean();
ob_start();
?>
It's important that you always restart output buffering as BigTree uses it to load your template into its layout.
Offline
Yep, that worked a treat, thanks!
I did run into a little bit of an issue with the $page_header from the last page loaded being inserted in place of the main page title, but I got around that by changing the key of the resources on the master template from $page_header to something different.
Thanks again!
Offline
Sweet, glad it worked for you!
Offline