Alex Posted November 14, 2011 Share Posted November 14, 2011 Hi, I am starting to play around with Processwire, I am looking at the news page example forum post here: http://processwire.com/talk/index.php/topic,442.0/prev_next,prev.html#new which talks about creating individual news story pages then displaying them on a news index page. Mine is not working yet, i have literally cut and paste what was in the above forum post... I created a news_story.php and news_index.php just using the basic example site templates Can someone point me in the right direction how to display the news stories on the news index page? Would be much appreciated to get me started on processwire basics. Here is a link to the live pages: http://www.hoof.net.au/pwire/news-page/ the code is here: news_story.php <?php /** * News Story * */ include("./head.inc"); ?> <h1><?=$page->title?></h1> <div id='bodycopy'> <?=$page->body?> </div> <?php include("./foot.inc"); news_index.php <?php include("./head.inc"); ?> <h1><?=$page->title?></h1> <?php // start the news stories list echo "<ul>"; // get the stories for this page $stories = $page->children("limit=4, sort=-date"); // note if you set the stories to sort by date descending on the /news/ page // in the admin, then you can omit the "sort=-date" above. // cycle through each story and print it in a <li> foreach($stories as $story) { echo " <li><a href='{$story->url}'>{$story->title}</a> <p><strong>Date:</strong> {$story->date}</p> {$story->body} </li> "; } echo "</ul>"; // get values for our placemarker headline $start = $stories->getStart(); $end = $start + count($stories); $total = $stories->getTotal(); $num = $input->pageNum; $lastNum = ceil($total / $stories->getLimit()); // output the placemarker headline echo "<h4>Showing $start - $end of $total Article/s | Page $num of $lastNum</h4>"; // output pagination links echo $stories->renderPager(); include("./foot.inc"); Regards, Alex Link to comment Share on other sites More sharing options...
Pete Posted November 14, 2011 Share Posted November 14, 2011 Can I just ask - did you create te news story itself UNDER the news index page? Looking the navigation on your page it looks like they're at the same level as a child story shouldn't be displaying there. If its not under the index page, go to the Pw admin and click on your news index page to open up the options, then click on your story, click Move and drag it so it's under the index page (it'll become indented). Link to comment Share on other sites More sharing options...
Alex Posted November 15, 2011 Author Share Posted November 15, 2011 Hi Pete, Thanks - yes worked straight away! Thanks, I think i am on my way now, loving it so far. I added a date field in the Setup area and changed my news_story.php so it displays that date: <?php /** * News Story * */ include("./head.inc"); ?> <h1><?=$page->title?></h1> <p><strong>Date: </strong><?=$page->date?></p> <div id='bodycopy'> <?=$page->body?> </div> <?php include("./foot.inc"); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now