Thanks for putting up with me !:)
It really feels like most of what I want will be here, eventually :
http://doc.silverstripe.com/doku.php?id=page-types
Going back to Tutorial 2:
A user creates a new ArticlePage, writes their article, puts in the date, but forgets to add their name.
How can I create a function from ArticlePage_Controller that sends back a boolean as to whether or not this particular ArticlePage has an author?
function hasAuthor(){
return this->'Author' !="" ? true : false;
}
Q. Is 'this->'Author' ' the correct way to get access to the data in the database as created by the user?
I realise that this is possible in the templating system with <% if $Author != ""> but what if I wanted to know whether or not a combination of things were in existence? Or at least a certain amount of the available fields were filled in?
Example: A postal address doesn't necessarily have to have all parts of the available fields to be correct. Example, some addresses have just building names, others have street numbers and names, some have suburbs and cities, others have just one or the other. So if we determine that a certain number of fields need to be entered to be correct, then we can count the number of fields and determine whether or not this entry has a postal address.
function postal(){
$postal = false;
$count = 0;
if (this->'Postal_Street' != "")
$count++;
if (this->'Postal_Suburb' !="")
$count++;
if (this->'Postal_Postcode' != "")
$count++;
return $count > 2? true : false;
}
Then in the template, this particular child would be queried if it had a postal address, and if it did,you would set up HTML code for the address and then you could query each field individually.