21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 632 Views |
-
Showing List of Members On A Page

11 May 2009 at 8:15am
I need to show the list of members in a group to approve based on a field in members
So, I created a MembersToApprovePage.php and extended Page with also a page controller.
- MembersToApprovePage.php
<?php
/**
* Defines the MembersToApprovePage page type
*/
class MembersToApprovePage extends Page {
static $db = array (
);
static $has_one = array (
);
static $allowed_children = array('MembersToApprovePage');
}
class MembersToApprovePage_Controller extends Page_Controller {function MembersNeedingApproval($num=10) {
$membersta = DataObject::get_one("MembersToApprovePage");
return ($membersta) ? DataObject::get("MembersToApprovePage", "ParentID = $membersta->ID", "DESC", "", $num) : false;
}
}
?>The Page shows up in the CMS fine when I create a page and select a page type, but it doesn't render and I get an error.
Does anyone know of a good tutorial that explains querying a table and showing the list on a page? I tried to emulate Tutorial-2 extending a basic site, but apparently not well enough.
Terry
-
Re: Showing List of Members On A Page

11 May 2009 at 11:46am
Hi Terry
What's the error that you get? Is it only failing when you call MembersNeedingApproval() from the template?
I think maybe your problem is get_one() - if you want multiple objects you'll need to use get() instead.
http://api.silverstripe.com/sapphire/core/DataObject.html#get
cheers,
David -
Re: Showing List of Members On A Page

11 May 2009 at 12:01pm
You might need to quote the ID in the DataObject get
return ($membersta) ? DataObject::get("MembersToApprovePage", "ParentID = '$membersta->ID'", "DESC", "", $num) : false;
| 632 Views | ||
|
Page:
1
|
Go to Top |



