User Tools

Site Tools


Birthdays: Separate page

Here we create a separate page with upcoming birthdays of site users.


  • Add “Birthdays” list to “Members” page

Implementation - Server Side (PHP)


// class that contains all data and functionality to add new type of members listing  
        class BIRTHDAYS_UsersPageData implements BASE_CLASS_IusersPageData

            //set menu item for "Birthdays" page
            public function getMenuItem()
                //$language - helps our site to be multilingual
                $language = OW::getLanguage();

                //initializing menu item
                $item = new BASE_MenuItem();

                $item->setLabel($language->text('base', 'user_list_menu_item_birthdays'))

                if ( $this->isCase() )
                    $item->setActive(true); // activate menu if "Birthdays" selected

                return $item;

            // check if URL is belong to "Birthdays" page
            public function isCase()
                return false !== strstr(OW::getRequest()->getRequestUri(), OW::getRouter()->uriForRoute('birthdays_users'));

            // "Birthdays" page's unique key
            public function getCase()
                return 'birthdays';

            // get data for "Birthdays" user listing
            public function getData( $first, $count )
                $service = BOL_UserService::getInstance();

                //set date bounds for birthdays
                $period = array(
                    'start' => date('Y-m-d'),
                    'end' => date('Y-m-d', strtotime('+7 day'))

                return array(
                    $service->findListByBirthdayPeriod($period['start'], $period['end'], $first, $count), // get users
                    $service->countByBirthdayPeriod($start, $end) // count users

        // register data for "Birthdays" page. 
        OW::getRegistry()->addToArray('users_page_data', new BIRTHDAYS_UsersPageData());

dev/tuts/birthdays-page.txt · Last modified: 2012/10/24 11:08 (external edit)