Hi Chaps,
Ive been following the tutorial here: http://doc.silverstripe.org/tutorial:2-extending-a-basic-site for creating an article system
which has been great. Got it working and very happy.
Ive then gone on to add the homepage controller which will show the 'Latest news' from the article page holder.
Which again has worked great.
My question is:
If i was to create 2 or more article holders with their article pages, could i like them both to work within the 'latest news' function?
EG:
IT News
---------> HomePage displaying the 5 latest news posts from both article holders?
HR News
HomePage.php
---------------------------------------------------------------
<?php
/**
* Defines the HomePage page type
*/
class HomePage extends Page {
static $db = array(
);
static $has_one = array(
);
}
class HomePage_Controller extends Page_Controller {
function LatestNews($num=5) {
$news = DataObject::get_one("ArticleHolder");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
}
}
?>
--------------------------------------------------------------------------------
ArticleHolder.php
---------------------------------------------------------------------------------
<?php
/**
* Defines the ArticleHolder page type
*/
class ArticleHolder extends Page {
static $db = array(
);
static $has_one = array(
);
static $allowed_children = array('ArticlePage');
}
class ArticleHolder_Controller extends Page_Controller {
}
?>
I know this is a bit complicated but if someone could point me in the right direction i would be VERY graeteful!
Many Thanks
Craig