batflat
batflat copied to clipboard
Najchętniej Czytane Posty
Witam. Udało mi się wyciągnać ze statystyk "najchętniej czytane /blog/posts/. Ale to tylko link. Bez polskich znaków i dostepu do zdjęcia coveru itp. Chciałbym zrobić typowo w blogu coś jak Najnowsze Posty tylko Najczęsciej oglądane.
$limit = $this->settings('blog.latestPostsCount');
$rows = $this->db('statistics')
->select([
'url',
'count_unique' => 'COUNT(DISTINCT uniqhash)',
'count' => 'COUNT(uniqhash)',
])
->like('url', '%/blog/post/%')
->group(['url'])
->desc('count')
->limit($limit)
->toArray();
foreach ($rows as $row) {
$row['link'] = str_replace('/blog/post/'," ", $row['url']);
$row['name'] = ucwords(str_replace('-'," ", $row['link']));
$result[] = $row;
}
return $result;
$limit = $this->settings('blog.latestPostsCount');
$rows = $this->db('blog')
->leftJoin('users', 'users.id = blog.user_id')
->where('status', 2)
->where('published_at', '<=', time())
->where('lang', $_SESSION['lang'])
->desc('published_at')
->limit($limit)
->select(['blog.id', 'blog.title', 'blog.slug', 'blog.intro', 'blog.content', 'users.username', 'users.fullname'])
->toArray();
foreach ($rows as &$row) {
$this->filterRecord($row);
}
return $rows;
Jakiś pomysł jak podłączyć te dwie bazy ?