Ok, finally figured it out from UncleCheeses code :)
Here is a brief explenation for anyone who is interested.
You need 2 functions in the ArticleHolder controller class, one to test if we are in view all mode and the other to return our Articles.
The first function is called from the template to decide whether to put a 'veiw all' link or a 'view some' link. It looks like this:
function ViewAll() {
$params = Director::urlParams();
return (isset($params['Action']) && $params['Action'] == 'showall');
}
The first line gets our URL parameters These are anything that follows the base URL, so for example if we type "www.oursite.com/article-holder/showall" the parameter that we provide is 'showall'.
Parameters are held in an array with keys of 'Action', 'ID', 'OtherID', corresponding to {pageURL}/Action/ID/OtherID.
In this case we only need to use the first perameter which is 'Action'.
We return a boolean based on whether 'Action' is set to 'showall'. Now if we typed in "{pageURL}/showall" and called ViewAll we would get a value of 1 or true.
Next is our actual article fetching function:
function NewsItems() {
if($this->ViewAll()){
return DataObject::get("ArticlePage", "ParentID = $this->ID", "Date DESC");
}
else{
return DataObject::get("ArticlePage", "ParentID = $this->ID", "Date DESC", "", "$this->Show");
}
}
The IF statement calls our first function and if we get a true, i.e. we are on the /showall page then it gets all the articles which are children of this holder, ELSE we just get the amount of articles that the $show variable (an int in $db) dictates.
Now we can create our template to use these functions:
<% if ViewAll %>
<a href="$Link" title="View paginated articles">View $Show Articles</a>
<% else %>
<a href="{$Link}showall" title="View all articles">View all Articles</a>
<% end_if %>
<% control NewsItems %>
{usual article Code}
<% end_control %>
Or first bit tests whetehr we are on the /showall page or just the normal page and adjusts teh link accordingly. The second bit then loops through each article and draws it as normal. I have left out all the HTML in this bit to avoid it getting cluttered :)
Anyway I hope that kindof makes sense and saves some people the caos of my last few hours! ;)
cheers
Aram