Hi,
I need help with trying to get the news items on the Article Holder page to show up. Been trying to get it to work for weeks.
Any help would be greatly appreciated. :D
http://www.teachsign.org.nz/
http://www.teachsign.org.nz/about-teachsign/updates
Here's the codes...
ArticleHolder.php:
<?php
class ArticleHolder extends Page {
static $db = array(
);
static $has_one = array(
);
static $allowed_children = array('ArticlePage');
private static $icon = "cms/images/treeicons/news.png";
}
class ArticleHolder_Controller extends Page_Controller {
}
ArticleHolder.ss:
<% include SideBar %>
<div class="content-container unit size3of4 lastUnit pages" id="article-page">
<% include BreadcrumbNavigationTemplateAllLinked %>
<div class="top-icon"><img src="{$ThemeDir}/images/page-icon-top.png" /></div>
<article>
<h1>$Title</h1>
<div class="content">$Content</div>
<% loop $Children %>
<article>
<h2><a href="$Link" title="Read more on "{$Title}"">$Title</a></h2>
<p class="newsDateTitle">$Date.Nice</p>
<p>$Content.FirstParagraph<span>...</span></p>
</article>
<% end_loop %>
$Form
</article>
</div>
ArticlePage.php:
<?php
class ArticlePage extends Page {
private static $db = array(
'Date' => 'Date',
'Author' => 'Text'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$dateField = new DateField('Date', 'Article Date (for example: 20/12/2010)');
$dateField->setConfig('showcalendar', true);
$dateField->setConfig('dateformat', 'dd/MM/YYYY');
$fields->addFieldToTab('Root.Main', $dateField, 'Content');
$fields->addFieldToTab('Root.Main', new TextField('Author', 'Author Name'), 'Content');
return $fields;
}
private static $icon = "cms/images/treeicons/news-listing.png";
}
class ArticlePage_Controller extends Page_Controller {
}
ArticlePage.ss:
<div class="content-container unit size3of4 lastUnit pages" id="article-page">
<% include BreadcrumbNavigationTemplateAllLinked %>
<div class="top-icon"><img src="{$ThemeDir}/images/page-icon-top.png" /></div>
<article>
<h1>$Title</h1>
<div class="news-details">
<p>Posted on $Date.Nice<!--by $Author--></p>
</div>
<div class="content">$Content</div>
</article>
$Form
</div>
HomePage.php:
class HomePage_Controller extends Page_Controller {
public function LatestNews($num=4) {
$holder = ArticleHolder::get()->First();
return ($holder) ? ArticlePage::get()->filter('ParentID', $holder->ID)->sort('Date DESC')->limit($num) : false;
}
}