Jump to content

santaji

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by santaji

  1. That was the problem. It's working great now! thanks.
  2. What's wrong with this code? function newsListTest() { //grab the page name $thisPage = wire("page")->path; //get the news posts $newsposts = wire("pages")->find("has_parent=$thisPage, template=news, sort=-date_time, limit = 10"); //Loop through the posts foreach($newsposts as $newspost){ $out .="<article class='newsarticle'>"; $out .="<a href='{$newspost->url}'><h3>{$newspost->title}</h3></a>"; $out .="<p>{$newspost->article_introtext}</p>"; $out .="</article>"; } } Getting these errors:
  3. I tried this code, doesn't work either. The original code was not written by me so i'm not sure how most of it works. Like i said, it's from this tutorial: http://wiki.processwire.com/index.php/Simple_News_System I will be trying to write my own code from scratch now. What i want to do is really simple, I have a page called "News Articles", and have set up the DateArchiver module to organize any pages created under it by year and month. So the structure is like this: - News Articles - 2013 - 01 - Articles made in January 2013 - 02 - Articles made in February 2013 So when on the 2013 page, the ArchivesNewsList function should display all articles that have 2013 as a parent, so all articles from 01 and 02. When on the 01 page for example, it should display all articles that have 01 as a parent, so only articles from that month.
  4. I tried doing something similar to how you've done the categories and the DateArchiver module. I was able to get a list of the years and months similar to the categories list but was not able to get the year/month pages to display the articles. Started a new topic here:http://processwire.com/talk/topic/3099-need-some-help-with-making-a-news-section-with-archives/
  5. Anybody have any ideas? This is the code i'm trying to get to display the posts in the archives pages: Basically it's function newsList() from Joss's tutorial, but i've changed has_parent=/news-articles to has_parent=$thisCategory Again, i don't know php, but the variable $thisCategory in the original code seems to be just the name of the current page? So shouldn't ("pages")->find("has_parent=$thisCategory get all the posts that are children of the current page? function ArchivesNewsList(){ // 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("has_parent=$thisCategory, template=news, sort=-date_time, limit=10"); $out =" "; //Loop through the pages foreach($newsposts as $newspost){ $out .="<div class='clearfix'>"; if($newspost->article_newsimage){ $out .="<a href='{$newspost->article_newsimage->url}' class=''>"; $out .="<img class='align_left' src='{$newspost->article_newsimage->getThumb(listingthumb)}'>"; $out .="</a>"; } $out .="<a href='{$newspost->url}'><h3>{$newspost->title}</h3></a>"; $out .="<p>{$newspost->article_introtext}</p>"; $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; } I tried removing template=news just to see what happens and this happened: Why is it displaying the options from the admin interface!? If i keep template=news in the wire("pages")->find selector nothing is displayed at all. So basically what i'm trying to do is getting the ArchivesNewsList() function to display all the article pages are are children of the current page, so if i'm on /2013 it should display all articles which are children of that page, /2013/03 should display articles that are children of /03, etc..
  6. I want to have a basic news system with the ability to filter posts by year and month to use on my websites. I used the code from this tutorial by Joss to set up the basic news system, than i installed and set up the DateArchiver module by u-nikos. I don't know php but i managed to reuse some of the code from the news_functions file from Joss's tutorial and got it to display the year and months: function archivesList(){ $years = wire("pages")->find("parent=/news-articles/, template=archives_index, sort=title"); $yearout =" "; foreach($years as $year){ $yearout .="<li><a href='{$year->url}'>{$year->title}</a></li>"; } echo "<ul>$yearout</ul>"; $pageName = wire("page")->name; if($pageName !="news") { $months = wire("pages")->find("parent=/news-articles/$pageName, template=archives_index, sort=title"); $monthout =" "; foreach($months as $month){ $monthout .="<li><a href='{$month->url}'>{$month->title}</a></li>"; } } echo "<ul>$monthout</ul>"; } Made an archives_index.php template for the year/month pages: <?php include("./header.inc"); include("./news_functions.inc"); // Give the news index page a title an a bit of an intro echo "<h1>{$page->title}</h1>"; echo $page->body; // Render the Category List categoriesList(); // Render the Archives List archivesList(); // Render the News List ArchivesNewsList(); include("./footer.inc"); But i can't figure out how to make the newsList() function from the tutorial filter the articles on the year and month pages.
  7. Thanks! that worked Is it possible to add a simple archives feature to this system? For browsing the articles by year and month?
  8. That was the problem. The news index, news article pages, and categories are now working perfectly. Only two issues i'm trying to figure out now. The news index shows the oldest post first. How do i get posts to display from the newest to the oldest? And the pagination does not work. I created 12 test articles under the news articles page, the first ten show up in the news index, but clicking next or 2 in the pagination does not load the second news index page. I can see ?page=2 in the address bar but the same page displays again.
  9. Hi, I'm new to ProcessWire and i'm learning how to implement it as a CMS. So far i'm finding it much more suited to my needs than WordPress, which is what i've used before. I've followed your Basic Website Tutorial but i'm having a problem with this one, basically this is what's happening: Heres my news-index.php file: <?php include("./header.inc"); include("./news_functions.inc"); // Give the news index page a title an a bit of an intro echo "<h1>{$page->title}</h1>"; echo $page->body; // Render the Category List categoriesList(); // Render the News List newsList(); include("./footer.inc"); news.php <?php include("./header.inc"); include("./news_functions.inc"); // Output the newsDisplay function newsDisplay(); include("./footer.inc"); and news-functions.inc /* 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=news, limit=10"); $out =" "; //Loop through the pages foreach($newsposts as $newspost){ $out .="<div class='clearfix'>"; if($newspost->article_newsimage){ $out .="<a href='{$newspost->article_newsimage->url}' class=''>"; $out .="<img class='align_left' src='{$newspost->article_newsimage->getThumb(listingthumb)}'>"; $out .="</a>"; } $out .="<a href='{$newspost->url}'><h3>{$newspost->title}</h3></a>"; $out .="<p>{$newspost->article_introtext}</p>"; $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=news_index, sort=title"); $out =" "; foreach($categories as $category){ $out .="<li><a href='{$category->url}'>{$category->title}</a></li>"; } echo "<ul>$out</ul>"; } I don't have much understanding of php so all the code is basically copy-pasted from your tutorial. I was able to get the news page to load correctly when i replaced "include("./news_functions.inc");" with the code from news-functions.inc in news-index.php, but it doesn't work with the include.
×
×
  • Create New...