Perhaps going into more detail will help me explain my problem in a real example. first, I'll show what I did to get it working - then what I would prefer to do.
in the controller I have these functions:
function getProfessors() {
return DataObject::get( 'FacultyPage', "`FacultyType` = 'Professor'" );
}
function getAssociateProfessors() {
return DataObject::get( 'FacultyPage', "`FacultyType` = 'Associate Professor'");
}
on the view I have this
<p>Professors</p>
<% control getProfessors %>
<p><a href="$Link">$Title</a></p>
<% end_control %>
<p>Associate Professors</p>
<% control getAssociateProfessors %>
<p><a href="$Link">$Title</a></p>
<% end_control %>
everything is kosher, but I have many types of professors and not only do I not want to have to write a new function for each one, but I want to be able to handle new kinds without going back to hack my classes. therefore, what I *want* to do is on the controller have this
function getFaculty($facultytype) {
return DataObject::get( 'FacultyPage', "`FacultyType` = '$facultytype'" );
}
and have this on my view
<p>Professors</p>
<% control getFaculty(Professor) %>
<p><a href="$Link">$Title</a></p>
<% end_control %>
<p>Associate Professors</p>
<% control getFaculty(Associate Professor) %>
<p><a href="$Link">$Title</a></p>
<% end_control %>
note that because the second one is 'associate professor' with a *space* it won't work. is this general type of problem to be solved in another way? I can see it coming up any time I want to sort data on my 'holder' pages.