Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Showing List of Members On A Page

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 748 Views
  • TerryMiddleton
    Community Member
    108 Posts

    Showing List of Members On A Page Link to this post

    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
    * 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.


  • david_nash
    Community Member
    55 Posts

    Re: Showing List of Members On A Page Link to this post

    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.



  • Willr
    Forum Moderator
    5508 Posts

    Re: Showing List of Members On A Page Link to this post

    You might need to quote the ID in the DataObject get

    return ($membersta) ? DataObject::get("MembersToApprovePage", "ParentID = '$membersta->ID'", "DESC", "", $num) : false;

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.