Created
November 6, 2019 11:30
-
-
Save Dmi3yy/3685d94e78379a12ccc241e28570a9b5 to your computer and use it in GitHub Desktop.
NewsController
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
<div class="news__block"> | |
@foreach($newsitems['docs'] as $item) | |
@include('partials.newsitem', ['item'=>$item]) | |
@endforeach | |
</div> | |
<nav class="pagination"> | |
@include('partials.paginate', ['paginate'=>$newsitems['pages']]) | |
</nav> |
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 | |
namespace EvolutionCMS\Odkb\Controllers; | |
class NewsController extends BaseController { | |
public function render() { | |
$this->data['newsmenu'] = json_decode($this->evo->runSnippet('DLMenu', ['parents' => 69, 'maxDepth' => 1, 'api' => 1]), true)[0]; | |
$this->data['newsitems'] = $this->DocLister([ | |
'depth'=>2, | |
'display'=>12, | |
'paginate'=>'pages', | |
'tvList'=>'important', | |
'saveDLObject' => '_DL' | |
]); | |
} | |
public function DocLister($data) { | |
$this->evo->runSnippet('DocLister', $data); | |
$_DL = $this->evo->getPlaceholder('_DL'); | |
$docs = $_DL->docsCollection() | |
->map(function(array $doc){ | |
$doc['date'] = $this->evo->runSnippet('aDate', ['date'=>$doc['createdon'], 'date2'=>$doc['publishedon']]); | |
return $doc; | |
}) | |
->toArray(); | |
$paginator = $_DL->getExtender('paginate'); | |
return [ | |
'docs'=>$docs, | |
'pages' => [ | |
'first' => 1, | |
'last' => $paginator->totalPage(), | |
'current' => $paginator->currentPage(), | |
'docs'=> $paginator->totalDocs() | |
] | |
]; | |
} | |
} |
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
<div class="news__item"> | |
<a href="@makeUrl($item['id'])" class="news__content @if( $item['tv.important'] == 1 ) news__important @endif"> | |
<h4>{{ $item['pagetitle'] }}</h4> | |
<div class="news__info"> | |
<div class="date">{!! $item['date'] !!}</div> | |
<span class="pdf"></span> | |
</div> | |
</a> | |
</div> |
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
@if ($paginate['last'] > 1 ) | |
<ul class="h4"> | |
@if($paginate['first'] == $paginate['current']) | |
<li><a href="" class="btn__prev btn__disabled"></a></li> | |
@elseif($paginate['current'] == 2) | |
<li><a href="@makeUrl($modx->documentIdentifier)" class="btn__prev"></a></li> | |
@else | |
<li><a href="@makeUrl($modx->documentIdentifier)?page={{ $paginate['current'] - 1 }}" class="btn__prev"></a></li> | |
@endif | |
@for ($i = $paginate['first']; $i <= $paginate['last']; $i++) | |
@if($i == $paginate['current']) | |
<li class="active">{{ $i }}</li> | |
@else | |
<li><a href="@makeUrl($modx->documentIdentifier)?page={{ $i }}">{{ $i }}</a></li> | |
@endif | |
@endfor | |
{{-- <li class="ellipsis"></li>--}} | |
@if($paginate['last'] == $paginate['current']) | |
<li><a href="" class="btn__next btn__disabled"></a></li> | |
@else | |
<li><a href="@makeUrl($modx->documentIdentifier)?page={{ $paginate['current'] + 1 }}" class="btn__next"></a></li> | |
@endif | |
</ul> | |
@endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment