Hello All,
I'm just starting my first PW build (and I love it so far.) I'm looking for some ideas on how others create reusable content, like sidebars or other content that may get displayed in any number of templates. I'm a long time Textpattern user, and reusable content like this is handled fairly easily. It appears to be just a simple with PW, but I'm still getting my head around the API. I thought I'd show my current thinking, and ask for any feedback or suggestion on alternate methods.
Basic example of reusable content:
On a home page I want to display the latest news item, and on another page I want to display the latest 3.
My current method is to call a template named news_posts.inc like so:
<?php $news = $pages->get("/news/")->children("limit=1");
include("./news_posts.inc"); ?>
To show more posts on another page, I just increase the limit.
For the sake of this example, let's say news_posts.inc just shows the title of each post:
<?php foreach ($news as $item)
echo "<p>{$item->title}</p>";
?>
This works fine, and is pretty straight-forward, I'm just curious if there are other methods or if I'm on the right path.