Fix #390 Incorrect number of pages being displayed

This commit is contained in:
Flavio Copes
2016-01-28 14:03:53 +01:00
parent 13c60ed833
commit c62fb6bdb5
3 changed files with 14 additions and 3 deletions

View File

@@ -330,6 +330,8 @@ class AdminPlugin extends Plugin
// make sure page is not frozen! // make sure page is not frozen!
unset($this->grav['page']); unset($this->grav['page']);
$this->admin->pagesCount();
// Replace page service with admin. // Replace page service with admin.
$this->grav['page'] = function () use ($self) { $this->grav['page'] = function () use ($self) {
$page = new Page; $page = new Page;

View File

@@ -75,6 +75,11 @@ class Admin
*/ */
protected $gpm; protected $gpm;
/**
* @var int
*/
protected $pages_count;
/** /**
* Constructor. * Constructor.
* *
@@ -404,9 +409,13 @@ class Admin
* *
* @return array * @return array
*/ */
public function countPages() public function pagesCount()
{ {
return count($this->grav['pages']->all()); if (!$this->pages_count) {
$this->pages_count = count($this->grav['pages']->all());
}
return $this->pages_count;
} }
/** /**

View File

@@ -34,7 +34,7 @@
<a href="{{ base_url_relative }}/pages"> <a href="{{ base_url_relative }}/pages">
<i class="fa fa-fw fa-file-text-o"></i> {{ "PLUGIN_ADMIN.PAGES"|tu }} <i class="fa fa-fw fa-file-text-o"></i> {{ "PLUGIN_ADMIN.PAGES"|tu }}
<span class="badges"> <span class="badges">
<span class="badge count">{{ admin.countPages }}</span> <span class="badge count">{{ admin.pagesCount }}</span>
</span> </span>
</a> </a>
</li> </li>