| | 30 | public function display($username = null) |
| | 31 | { |
| | 32 | if ($username == null): |
| | 33 | $this->redirect("/"); |
| | 34 | return false; |
| | 35 | endif; |
| | 36 | |
| | 37 | $this->pageTitle = $username . '\'s Blog'; |
| | 38 | |
| | 39 | $user_id = $this->Entry->User->field('id', array('username'=>$username)); |
| | 40 | |
| | 41 | $conditions = array('Entry.user_id'=>$user_id, 'Entry.status'=>1); |
| | 42 | |
| | 43 | $data = $this->paginate('Entry', $conditions); |
| | 44 | |
| | 45 | $this->set(compact('data')); |
| | 46 | |
| | 47 | $this->layout = $this->Edublog->layout($user_id); |
| | 48 | |
| | 49 | $this->Edublog->blog($user_id); |
| | 50 | } |
| | 51 | |
| | 52 | public function view($username, $entry_id) |
| | 53 | { |
| | 54 | if ($entry_id == null): |
| | 55 | $this->redirect('/blog/'.$username); |
| | 56 | return false; |
| | 57 | endif; |
| | 58 | |
| | 59 | $this->pageTitle = $username . '\'s Blog'; |
| | 60 | |
| | 61 | $user_id = $this->Entry->User->field('User.id', array("username"=>$username)); |
| | 62 | |
| | 63 | if ($username == null || $user_id == null): |
| | 64 | $this->redirect("/"); |
| | 65 | return false; |
| | 66 | endif; |
| | 67 | |
| | 68 | $conditions = array('Entry.user_id'=>$user_id, 'Entry.status'=>1, 'Entry.id'=>$entry_id); |
| | 69 | |
| | 70 | $fields = array("Entry.title", "Entry.body", "Entry.created", "Entry.user_id", "Entry.discution", "Entry.subject_id", "Entry.id", "User.username", "Subject.title", "Subject.id"); |
| | 71 | |
| | 72 | $this->set('data', $this->Entry->find($conditions, $fields)); |
| | 73 | |
| | 74 | $this->layout = $this->Edublog->layout($user_id); |
| | 75 | |
| | 76 | $this->Edublog->blog($user_id); // blogger elements |
| | 77 | } |
| | 78 | |
| | 79 | |