Olli Posted January 9, 2016 Share Posted January 9, 2016 Hey I'm trying to output on my frontpage the latest news but I keep getting a output of "". The sitemap looks something like this:Homepage -news page (uses template "news") --news listed separately as children to "news page" This is the probably the closest I have gotten to the right answer. So get the pages with template "news", which is just one page, and get the children of it. Am I missing something here? <?php foreach ($pages->get('template=news')->children as $news) { ?> <h1><?php $news->title ?></h1> <?php } ?> I have some dull information in the backend so I am expecting some output. Any ideas? Link to comment Share on other sites More sharing options...
Tom. Posted January 9, 2016 Share Posted January 9, 2016 Inside that foreach, add another using $news->children as $news. I would give a better code example, but I'm on my mobile. Sorry, I can't find the edit button on the mobile site. But I just noticed you aren't echoing out your title you need to use <?=$news->title?> 1 Link to comment Share on other sites More sharing options...
Olli Posted January 9, 2016 Author Share Posted January 9, 2016 (edited) Well that was it I also got lost in my several template files but that final echoing fixed my problem Now my next task is to sort them by date... we'll see if I need help with that too... Edit: ("limit=3, sort=-date") seems to do most of the magic, just need to get the date sort to show latest first. Edit: wrong syntax... ("limit=3, sort=-created") yey! Edited January 9, 2016 by Olli 1 Link to comment Share on other sites More sharing options...
Olli Posted January 10, 2016 Author Share Posted January 10, 2016 I'm getting the news content as wished but now I'm in trouble with the word count. As the foreach spits out the full length of the body text, I would need to limit this to e.g. 200 characters. Any ideas how that would be made with processwire or do I have to use normal php functions to limit it. Alternatively, I could make 2 bodys, one where the intro text is and another for the full text, this is more work for the publisher tho... Link to comment Share on other sites More sharing options...
Macrura Posted January 11, 2016 Share Posted January 11, 2016 WordLimiter anyone? https://processwire.com/talk/topic/3429-how-to-set-text-linecharacter-limits-in-templates/?p=33779 https://processwire.com/talk/topic/11606-how-to-generate-auto-summary-of-long-cnkeditor-content-with-valid-xhtml/?p=108088 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