Merge pull request #2953 from jordanmkoncz/patch-1

Fixed inconsistencies and out of date information
This commit is contained in:
Simon Welsh 2014-03-14 23:45:45 +13:00
commit 7f704cfc97

View File

@ -200,10 +200,12 @@ the date field will have the date format defined by your locale.
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', $dateField = new DateField('Date','Article Date (for example: 20/12/2010)'), 'Content');
$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'), 'Content');
$fields->addFieldToTab('Root.Main', new TextField('Author', 'Author Name'), 'Content');
return $fields;
}
@ -211,7 +213,7 @@ the date field will have the date format defined by your locale.
Let's walk through these changes.
:::php
$fields->addFieldToTab('Root.Main', $dateField = new DateField('Date','Article Date (for example: 20/12/2010)'), 'Content');
$dateField = new DateField('Date', 'Article Date (for example: 20/12/2010)');
*$dateField* is declared in order to change the configuration of the DateField.
@ -335,19 +337,23 @@ Now let's make a purely cosmetic change that nevertheless helps to make the info
Add the following field to the *ArticleHolder* and *ArticlePage* classes:
:::php
private static $icon = "framework/docs/en/tutorials/_images/treeicons/news-file.gif";
private static $icon = "cms/images/treeicons/news-file.gif";
And this one to the *HomePage* class:
:::php
private static $icon = "framework/docs/en/tutorials/_images/treeicons/home-file.gif";
private static $icon = "cms/images/treeicons/home-file.png";
This will change the icons for the pages in the CMS.
![](_images/tutorial2_icons2.jpg)
<div class="hint" markdown="1">
Note: The `news-file` icon may not exist in a default SilverStripe install. Try adding your own image, or choosing a different one from the `tree-icons` collection.
</div>
## Showing the latest news on the homepage
It would be nice to greet page visitors with a summary of the latest news when they visit the homepage. This requires a little more code though - the news articles are not direct children of the homepage, so we can't use the *Children* control. We can get the data for news articles by implementing our own function in *HomePage_Controller*.