davo Posted October 26, 2013 Share Posted October 26, 2013 So I've followed a number of tutorials this week and combined them together making some really cool adaptions. But, the part that I can't get to work is the simple news tutorial: http://wiki.processwire.com/index.php/Simple_News_System I've used the functions page as below and pagination, is the only part that I've not messed about with; but in reality, the only parts of the code i've changed is the sort order where I've asked it to be sorted by reverse natural sort order I think; this is so I get the newest news articles first. The pagination function just seems to return the same page each time. <?php /* LIST ARTICLES This displays a list of articles in div containers on the news-index page. */ function newsList(){ // Grab the page name from the url $thisCategory = wire("page")->name; // If the category is not called "news" then output the category name as a selector for the find. if($thisCategory !="news") { $category = "article_category.name=" . $thisCategory; } // Get the news posts - limited to ten for later pagination $newsposts = wire("pages")->find("parent=/news-articles/, $category, template=TUT_news, sort=-sort, limit=10"); $out =" "; //Loop through the pages foreach($newsposts as $newspost){ $out .="<div class='clearfix'><hr>"; $out .="<BR><a href='{$newspost->url}'><h3>{$newspost->title}</h3></a>"; if($newspost->article_thumbnails){ $out .="<a href='{$newspost->article_thumbnails->url}' class=''>"; $out .="<img class='' src='{$newspost->article_thumbnails->getThumb(listingthumb)}'>"; $out .="</a>"; } // $out .="<a href='{$newspost->url}'><h3>{$newspost->title}</h3></a>"; $out .="<p>{$newspost->article_introtext}<a href='{$newspost->url}'> Read more...</a></p><br>"; $out .="</div>"; } // Pagination $out .="<div class='pagination'>"; $out .= $newsposts->renderPager(array( 'nextItemLabel' => "Next", 'previousItemLabel' => "Prev", 'listMarkup' => "<ul>{out}</ul>", 'itemMarkup' => "<li>{out}</li>", 'linkMarkup' => "<a href='{url}'>{out}</a>" )); $out .="</div>"; echo $out; } /* CATEGORIES LIST This lists available categories */ function categoriesList(){ $categories = wire("pages")->find("parent=/categories/, template=TUT_news.index, sort=title"); $out =" "; foreach($categories as $category){ $out .="<li><a href='{$category->url}'>{$category->title}</a></li>"; } echo "<ul>$out</ul>"; } /* DISPLAY ARTICLE This displays the article on the news page. You can change the <a> class if you are using a lightbox */ function newsDisplay(){ $newspost = wire("page"); $out =" "; if($newspost->article_thumbnails){ $out .="<a href='{$newspost->article_thumbnails->url}' class=''>"; $out .="<img class='align_right' src='{$newspost->article_thumbnails->getThumb(thumbnail)}'>"; $out .="</a>"; } // $out .="<h2>{$newspost->title}</h2>"; $out .=$newspost->article_maintext; echo "<div class='clearfix'>$out</div>"; } /* first attempt at newsblock */ function newsblock(){ // Get the news posts - limited to ten for later pagination $blocknewsposts = wire("pages")->find("parent=/news-articles/, article_thumbnails!='', template=TUT_news, sort=-sort, limit=12"); $out =" "; //Loop through the pages foreach($blocknewsposts as $blocknewspost){ // $out .="<div class='clearfix'>"; if($blocknewspost->article_thumbnails){ $out .="<a href='{$blocknewspost->url}' class=''>"; $out .="<img class='' src='{$blocknewspost->article_thumbnails->getThumb(listingthumb)}'>"; $out .="</a>"; } // $out .="</div>"; } echo $out; } ?> The page renders like this: http://www.garagesalefinder.co.uk/news/ I understand most of the code, but I do get a little lost understanding the pagination code, which makes it difficult for me to debug. I've made an image block at the end of it too which i've very please with, but the problem was there prior to that. Link to comment Share on other sites More sharing options...
diogo Posted October 26, 2013 Share Posted October 26, 2013 Hi Davo. Make sure you have pagination activated on the settings of this template. Link to comment Share on other sites More sharing options...
davo Posted October 26, 2013 Author Share Posted October 26, 2013 Thanks Diogo That sounded like it was going to work; I edited the template settings and Allow Page Numbers? and I also checked Allow URL Segments? Was this what you meant? sadly this didn't work; any other ideas please? Link to comment Share on other sites More sharing options...
davo Posted October 27, 2013 Author Share Posted October 27, 2013 Or I could turn it on for the correct template. Thank you. Solved! 1 Link to comment Share on other sites More sharing options...
opalepatrick Posted December 16, 2014 Share Posted December 16, 2014 Hi Davo. Make sure you have pagination activated on the settings of this template. Everytime... Everytime I forget that one 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