diff --git a/PageHitCounter.less b/PageHitCounter.less index 379dbea..61aa967 100644 --- a/PageHitCounter.less +++ b/PageHitCounter.less @@ -47,4 +47,8 @@ div.pageListHitCounterWrapper { } } +div.pageListHitCounterWrapper_after { + margin-left: 10px; +} + span.resetResultInfo {color: #da4949} diff --git a/PageHitCounter.min.css b/PageHitCounter.min.css index a094608..f3ca56e 100644 --- a/PageHitCounter.min.css +++ b/PageHitCounter.min.css @@ -1 +1 @@ -div.pageListHitCounterWrapper{margin-right:10px;display:inline-block;min-width:70px}div.pageListHitCounterWrapper span.pageListHitCounter{background:#e8e8e8;padding:0 10px;border-radius:50px;font-size:.8rem;min-width:65px;display:inline-block;text-align:left}div.pageListHitCounterWrapper span.pageListHitCounter i{color:#767676!important;font-size:inherit!important;margin-right:2px!important}span.resetResultInfo{color:#da4949} \ No newline at end of file +div.pageListHitCounterWrapper{margin-right:10px;display:inline-block;min-width:70px}div.pageListHitCounterWrapper_after{margin-left: 10px;}div.pageListHitCounterWrapper span.pageListHitCounter{background:#e8e8e8;padding:0 10px;border-radius:50px;font-size:.8rem;min-width:65px;display:inline-block;text-align:left}div.pageListHitCounterWrapper span.pageListHitCounter i{color:#767676!important;font-size:inherit!important;margin-right:2px!important}span.resetResultInfo{color:#da4949} diff --git a/PageHitCounter.module b/PageHitCounter.module index cc435d2..7ca0b3c 100644 --- a/PageHitCounter.module +++ b/PageHitCounter.module @@ -85,6 +85,7 @@ class PageHitCounter extends WireData implements Module, ConfigurableModule { 'customAttributes' => 'defer', 'forRoles' => array(), 'showForBackend' => 1, + 'placeAfter' => 0, 'ipValidation' => 1, 'excludeTemplates' => array() ); @@ -159,6 +160,7 @@ class PageHitCounter extends WireData implements Module, ConfigurableModule { $customAttributes = (string) $input->post->customAttributes; $forRoles = (array) $input->post->forRoles; $showForBackend = (int) $input->post->showForBackend; + $placeAfter = (int) $input->post->placeAfter; $ipValidation = (int) $input->post->ipValidation; $excludeTemplates = (array) $input->post->excludeTemplates; @@ -272,13 +274,28 @@ class PageHitCounter extends WireData implements Module, ConfigurableModule { $field->label = __("Show counter in page tree"); $field->checkboxLabel = __("Show counter"); $field->icon = "eye"; - $field->columnWidth = '50'; + $field->columnWidth = '25'; $field->checked = ($data['showForBackend']) ? 'checked' : ''; $field->description = __("Should a counter be displayed in the admin page tree?"); $field->notes = __("You can also output the counter yourself with the field name \"phits\"."); $field->value = $data['showForBackend']; $form->add($field); + // ------------------------------------------------------------------------ + // Place after page title + // ------------------------------------------------------------------------ + $field = $modules->get("InputfieldCheckbox"); + $field->name = "placeAfter"; + $field->label = __("Place counter after page title"); + $field->checkboxLabel = __("Place after"); + $field->showIf = "showForBackend=1"; + $field->icon = "align-right"; + $field->columnWidth = '25'; + $field->checked = ($data['placeAfter']) ? 'checked' : ''; + $field->description = __("Should the counter be placed after the page title in the admin page tree?"); + $field->value = $data['placeAfter']; + $form->add($field); + // ------------------------------------------------------------------------ // Template select for excluding in page tree // ------------------------------------------------------------------------ @@ -456,7 +473,7 @@ class PageHitCounter extends WireData implements Module, ConfigurableModule { // ------------------------------------------------------------------------ // Show counter in page tree // ------------------------------------------------------------------------ - if($this->showForBackend) { + if($this->showForBackend AND $this->wire->input->get('mode') != 'select') { $this->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'addPageListHitCounter'); wire('config')->styles->add($this->config->urls->PageHitCounter . 'PageHitCounter.min.css'); } @@ -968,7 +985,11 @@ class PageHitCounter extends WireData implements Module, ConfigurableModule { // ------------------------------------------------------------------------ // Else get hits and return event // ------------------------------------------------------------------------ - $event->return = $this->buildPageListHitCounter((int) $page->get(self::PHCFIELDNAME), $page->lastPageHit) . $event->return; + if($this->placeAfter){ + $event->return = $event->return . $this->buildPageListHitCounter((int) $page->get(self::PHCFIELDNAME), $page->lastPageHit) ; + } else { + $event->return = $this->buildPageListHitCounter((int) $page->get(self::PHCFIELDNAME), $page->lastPageHit) . $event->return; + } } /** @@ -982,7 +1003,8 @@ class PageHitCounter extends WireData implements Module, ConfigurableModule { public function buildPageListHitCounter($number, $lastHit = NULL) { $_lastHit = ($lastHit !== NULL OR !empty($lastHit)) ? ' ' . $this->_('Last viewed on:') . ' ' . $this->datetime->date('relative', $lastHit) . ' (' . $this->datetime->date('', $lastHit) . ')' : ''; $_counter = number_format($number, 0, ',', $this->thousandSeparator); - return "
+ $_afterClass = ($this->placeAfter) ? ' pageListHitCounterWrapper_after' : ''; + return "
". $_counter ."