Created
July 22, 2016 01:54
-
-
Save markstory/d344cff70c1a8d21d2f0cf50fd9262ba to your computer and use it in GitHub Desktop.
issue 9152
This file contains hidden or 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 | |
namespace App\Controller; | |
use App\Controller\AppController; | |
use Cake\Event\Event; | |
use Cake\Mailer\MailerAwareTrait; | |
/** | |
* Bookmarks Controller | |
* | |
* @property App\Model\Table\BookmarksTable $Bookmarks | |
*/ | |
class BookmarksController extends AppController | |
{ | |
public $components = ['RequestHandler', 'Paginator']; | |
/** | |
* Index method | |
* | |
* @return void | |
*/ | |
public function index() | |
{ | |
$options = [ | |
'limit' => 5, | |
'sortWhitelist' => ['name', 'create'], | |
'order' => ['name' => 'asc'] | |
]; | |
$query = $this->Bookmarks->find() | |
->select(['name' => 'Bookmarks.title', 'create' => 'Bookmarks.created']) | |
->autoFields(true); | |
$this->set('bookmarks', $this->Paginator->paginate($query, $options)); | |
$this->set('_serialize', ['bookmarks']); | |
} | |
} |
This file contains hidden or 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
<div class="bookmarks index large-10 medium-9 columns"> | |
<table cellpadding="0" cellspacing="0"> | |
<thead> | |
<tr> | |
<th><?= $this->Paginator->sort('user_id') ?></th> | |
<th><?= $this->Paginator->sort('name') ?></th> | |
<th><?= $this->Paginator->sort('create', 'Created At') ?></th> | |
<th><?= $this->Paginator->sort('updated') ?></th> | |
<th class="actions"><?= __('Actions') ?></th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php foreach ($bookmarks as $bookmark): ?> | |
<tr> | |
<td> | |
<?= $bookmark->has('user') ? $this->Html->link($bookmark->user->id, ['controller' => 'Users', 'action' => 'view', $bookmark->user->id]) : '' ?> | |
</td> | |
<td><?= h($bookmark->title) ?></td> | |
<td><?= $this->Time->i18nFormat($bookmark->created) ?></td> | |
<td><?= h($bookmark->updated) ?></td> | |
<td class="actions"> | |
<?= $this->Html->link(__('View'), ['action' => 'view', $bookmark->id]) ?> | |
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $bookmark->id]) ?> | |
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $bookmark->id], ['confirm' => __('ingAre you sure you want to delete # {0}?', $bookmark->id)]) ?> | |
</td> | |
</tr> | |
<?php endforeach; ?> | |
</tbody> | |
</table> | |
<div class="paginator"> | |
<ul class="pagination"> | |
<?= $this->Paginator->prev('< ' . __('previous')) ?> | |
<?= $this->Paginator->numbers() ?> | |
<?= $this->Paginator->next(__('next') . ' >') ?> | |
</ul> | |
<p><?= $this->Paginator->counter() ?></p> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment