Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Najchętniej Czytane Posty #111

Open
Dejmienwp opened this issue Jun 21, 2021 · 0 comments
Open

Najchętniej Czytane Posty #111

Dejmienwp opened this issue Jun 21, 2021 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@Dejmienwp
Copy link

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 ?

@michu2k michu2k added the help wanted Extra attention is needed label Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants