Created
May 2, 2014 18:53
-
-
Save swthate/f5efe962a2228422793d to your computer and use it in GitHub Desktop.
Display Comment Username
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// debug($commentAuthor['User']); | |
array( | |
'password' => '*****', | |
'id' => '9', | |
'username' => 'Steven', | |
'created' => '2014-04-25 20:42:51', | |
'modified' => '2014-04-25 20:42:51' | |
) | |
// debug($commentAuthor['User']['username']); | |
'Steven' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* view method | |
* | |
* @throws NotFoundException | |
* @param string $id | |
* @return void | |
*/ | |
public function view($id = null) { | |
if (!$this->Job->exists($id)) { | |
throw new NotFoundException(__('Invalid job')); | |
} | |
$options = array('conditions' => array('Job.' . $this->Job->primaryKey => $id)); | |
$this->set('job', $this->Job->find('first', $options)); | |
$this->loadModel('User'); | |
$this->set('commentAuthor', $this->User->findById('9')); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- File: /app/View/Jobs/view.ctp --> | |
<!-- Comments List ................................... --> | |
<h3>Comments</h3> | |
<?php foreach ($job['Comment'] as $comment): ?> | |
<div class="panel"> | |
<h4><?php echo $comment['title'];?></h4> | |
<p>By <?php echo $comment['user_id'];?></p> | |
<p><?php echo $comment['text'];?></p> | |
</div> | |
<?php endforeach; ?> | |
<?php debug($commentAuthor['User']['username']); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment