<h2 class="blog-news-title"><?= \S::lang( 'zobacz-inne-artykuly' );?></h2>
<?
global $mdb, $lang_id;

$results = $mdb -> query( 'SELECT * FROM ( '
                                . 'SELECT '
                                    . 'a.id, date_modify, date_add, o, priority, '
                                    . '( CASE '
                                      . 'WHEN copy_from IS NULL THEN title '
                                      . 'WHEN copy_from IS NOT NULL THEN ( '
                                        . 'SELECT '
                                          . 'title '
                                        . 'FROM '
                                          . 'pp_articles_langs '
                                        . 'WHERE '
                                          . 'lang_id = al.copy_from AND article_id = a.id '
                                        . ') '
                                     . 'END ) AS title '
                                . 'FROM '
                                  . 'pp_articles_pages AS ap '
                                  . 'INNER JOIN pp_articles AS a ON a.id = ap.article_id '
                                  . 'INNER JOIN pp_articles_langs AS al ON al.article_id = ap.article_id '
                                . 'WHERE '
                                  . 'status = 1 AND page_id = 6 AND lang_id = \'' . $lang_id . '\' '
                            . ') AS q1 '
                            . 'WHERE '
                              . 'q1.title IS NOT NULL '
                            . 'ORDER BY RAND() '
                              . 'LIMIT 3' ) -> fetchAll();
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
  $articles[] = $row['id'];

if ( is_array( $articles ) and count( $articles ) )
{
  foreach ( $articles as $article )
    $articles_details[] = \front\factory\Articles::article_details( $article, $lang_id );

  $tpl = new \Tpl;
  $tpl -> articles  = $articles_details;
  echo $tpl -> render( 'articles/articles-entries' );
}