Beispiel #1
0
use frontend\models\ArticleContent;
use pavlinter\display\DisplayImage;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Inflector;
use yii\helpers\StringHelper;
if ($items) {
    echo '<div class="perexes-list">';
    if ($columnsCount > 3) {
        $columnsCount = 3;
    }
    $i = 0;
    foreach ($items as $item) {
        $articleUrlParts = ['page/article', 'ida' => $item->id, 'article' => Inflector::slug(strip_tags($item->title)), 'web' => \Yii::$app->request->get('web'), 'language' => \Yii::$app->request->get('language')];
        if (!$menuUrlParts) {
            $menuUrlParts = ArticleContent::getMenuUrlParts($item->id);
        }
        $url = ArrayHelper::merge($articleUrlParts, $menuUrlParts);
        $test = $i % $columnsCount;
        if ($test == 0) {
            echo '<div class="row">';
        }
        echo '<div class="col s12' . ($columnsCount == 2 ? ' l6' : ($columnsCount == 3 ? ' l4' : '')) . '">';
        echo '<div class="row">';
        if ($withImage) {
            echo '<div class="col s12 l1">';
            if (isset($item->image)) {
                $image = DisplayImage::widget(['width' => $maxImageSize['width'], 'height' => $maxImageSize['height'], 'options' => ['class' => 'responsive-img hoverable', 'title' => $item->title], 'category' => 'all', 'image' => $item->image->filename]);
                echo Html::a($image, $url);
            }
            echo '</div>';
            $invitationsMenuUrlParts = ArticleContent::getMenuUrlParts($item->id);
        }
        $url = ArrayHelper::merge($articleUrlParts, $invitationsMenuUrlParts);
        echo $this->renderFile('@frontend/components/homepage/views/_invitationActuality.php', ['item' => $item, 'url' => $url, 'maxImageSize' => $maxImageSize, 'wordsCount' => $wordsCount, 'columnsCount' => $columnsCount, 'itemType' => 'invitation']);
        if ($test == $columnsCount - 1) {
            echo '</div>';
        }
        ++$i;
    }
    foreach ($actualitiesItems as $item) {
        $test = $i % $columnsCount;
        if ($test == 0) {
            echo '<div class="row">';
        }
        $articleUrlParts = ['page/article', 'ida' => $item->id, 'article' => Inflector::slug(strip_tags($item->title)), 'web' => \Yii::$app->request->get('web'), 'language' => \Yii::$app->request->get('language')];
        if (!$actualitiesMenuUrlParts) {
            $actualitiesMenuUrlParts = ArticleContent::getMenuUrlParts($item->id);
        }
        $url = ArrayHelper::merge($articleUrlParts, $actualitiesMenuUrlParts);
        echo $this->renderFile('@frontend/components/homepage/views/_invitationActuality.php', ['item' => $item, 'url' => $url, 'maxImageSize' => $maxImageSize, 'wordsCount' => $wordsCount, 'columnsCount' => $columnsCount, 'itemType' => 'actuality']);
        if ($test == $columnsCount - 1) {
            echo '</div>';
        }
        ++$i;
    }
    if ($test != $columnsCount - 1) {
        echo '</div>';
    }
    echo '</div>';
    echo '</div>';
}