Profiles and Statuses Profile link The link to view a user''s profile will simply be: profile/view/userid,. This enacts the profile controller, which in turn passes control to the profile information controller. We need to add this link to the following templates we already have: • • Views/default/templates/members/list.tpl.php Views/default/templates/members/search.tpl.php The link is shown below: DINO SPACE! Members List {letter} {name} Keeper of {dino_name} a {dino_gender} {dino_breed} {form_relationship} The profile information controller (controllers/profile/ profileinformationcontroller.php) needs to communicate with the model, Controller to get the data for the profile, and have the data assigned to template variables. We already have a method in the controller to do this,...
Profiles and Statuses Profile link The link to view a user's profile will simply be: profile/view/userid, This enacts the profile controller, which in turn passes control to the profile information controller We need to add this link to the following templates we already have: • • Views/default/templates/members/list.tpl.php Views/default/templates/members/search.tpl.php The link is shown below: DINO SPACE! Members List {letter}{name}
Keeper of {dino_name} a {dino_gender} {dino_breed}
{form_relationship} Controller The profile information controller (controllers/profile/ profileinformationcontroller.php) needs to communicate with the model, to get the data for the profile, and have the data assigned to template variables We already have a method in the controller to this, so it should be a fairly trivial task: include the model, and call the toTags method to push the profile information to template tags, as highlighted in the code below: Template The template for this aspect of the profile is shown below (views/default/ templates/profile/information/view.tpl.php); the highlighted aspects show the common template information shared by all aspects of the profile (including aspects we may add in the future) Friends- {users_name}
- View all
- View mutual friends [ 153 ] Download from www.eBookTM.com This material is copyright and is licensed for the sole use by RAYMOND ERAZO on 25th October 2010 3146 KERNAN LAKE CIRCLE, JACKSONVILLE, 32246 Profiles and Statuses
- Status updates
{p_bio}
My Dinosaur Name {p_dino_name} DOB {p_dino_dob} Breed {p_dino_breed} Gender {p_dino_gender} In action If we now visit a user's profile (http://localhost/folder-containingsocialnetwork/profile/view/1), we see the user's profile on the screen as shown in the following screenshot: [ 154 ] Download from www.eBookTM.com This material is copyright and is licensed for the sole use by RAYMOND ERAZO on 25th October 2010 3146 KERNAN LAKE CIRCLE, JACKSONVILLE, 32246 Chapter Relationships—some improvements At present, our relationships controller is only set to either list our relationships with other users, or pending relationship requests It isn't set up to show all of the contacts of a user, or all of the mutual contacts we have in common with a user Let's extend our relationships controller to facilitate these; after all, we have placed a link to them on our profile pages All contacts To get a list of all the contacts of a user, we simply require the relationships model, and call the getRelationships method, passing the user whose profile we were viewing: /** * View all users connections * @param int $user * @return void */ private function viewAll( $user ) { if( $this->registry->getObject('authenticate')->isLoggedIn() ) { require_once( FRAMEWORK_PATH 'models/relationships.php'); $relationships = new Relationships( $this->registry ); $all = $relationships->getByUser( $user, false, ); $this->registry->getObject('template')[ 155 ] Download from www.eBookTM.com This material is copyright and is licensed for the sole use by RAYMOND ERAZO on 25th October 2010 3146 KERNAN LAKE CIRCLE, JACKSONVILLE, 32246 Profiles and Statuses >buildFromTemplates('header.tpl.php', 'friends/all.tpl.php', 'footer.tpl.php'); $this->registry->getObject('template')->getPage()->addTag('all', array( 'SQL', $all ) ); require_once( FRAMEWORK_PATH 'models/profile.php'); $p = new Profile( $this->registry, $user ); $name = $p->getName(); $this->registry->getObject('template')->getPage()->addTag( 'connecting_name', $name ); } else { $this->registry->errorPage( 'Please login', 'Please login to view a users connections'); } } Template We need a template file called views/default/templates/friends/all.tpl.php to act as the template for viewing all of a user's friends Connections of {connecting_name}- {plural_name} with {users_name}