Перейти к содержанию
CMSTOOLS.org - форум поддержки и развития CMS

[Модуль] вывод блоков виде кирпичной кладки


Рекомендуемые сообщения

1. Заходим в system Открыть Файл init.php
Ищем:

include ENGINE_DIR.'/classes/templates.php';

Ниже ставим

include ENGINE_DIR.'/classes/Masonry.php';

ищем:

if($config['gzip'] == 'yes') include ENGINE_DIR.'/modules/gzip.php';

Ниже ставим

$masonry = new Masonry();

2. Заходим в templates\Default\js

Открыть Файл main.js

Ищем:

var url_next_id = 1;

Ниже ставим

function set_collage(id){
var collage = document.getElementById(id);
var images = collage.getElementsByTagName('img');
    //Маленький набор опций: averageRowHeight - примерная высота строки; gap - отступы между картинками;
    var options = {averageRowHeight: 175, gap: 3};
    var widths = [], rows = [], rowNumber = 0, index = 0, k = 0;
    //Записываем в массив ширину каждой картинки при одинаковой высоте
for(var i = 0; i < images.length; i++){
widths.push(Math.round(images[i].width / images[i].height * options.averageRowHeight));
}
    //Функция суммы элементов массива
    Array.prototype.sum = function(){
        return this.reduce( function(prev,current){ return  +current + prev; }, 0);
    }
    //Разбиение оизображений на строки обичным деление общей ширины всех картинок на ширину контейнера
    while(rowNumber < Math.ceil(widths.sum() / collage.clientWidth)){
        rows[rowNumber] = [];
        //Как только общая ширина картинок превысила ширину контейнера переходим на следующую строку
        while(index < widths.length && rows[rowNumber].sum()+(rows[rowNumber].length * options.gap) < collage.clientWidth + options.gap){
            rows[rowNumber].push(widths[index]);
            index++;
            //Если на последнюю строку осталось одно изображение, то дописываем его в "предпоследнюю"
            if(index == widths.length - 1){
                rows[rowNumber].push(widths[index]);
                rowNumber++;
                break;
            }
        }
        rowNumber++;
    }
    index = 0;
    //Непосредственно изменение масштаба картинок (пропорционально, без обрезания изображений)
    for(var i = 0; i < rows.length; i++){
        for(var j = 0; j < rows[i].length; j++){
            // Если ширина строки больше/меньше ширины контейнера - соответственно
            // уменьшаем/увеличиваем до ширины контейнера с учетем отступов между картинками
            k = (collage.clientWidth - ((rows[i].length - 1) * options.gap)) / rows[i].sum();
            images[index].style.width = rows[i][j] * k  + 'px';
            images[index].style.height = k * options.averageRowHeight + 'px';
            if(j < rows[i].length - 1) images[index].style.marginRight = options.gap + 'px';
            if(i < rows.length - 1) images[index].style.marginBottom = options.gap + 'px';
            index++;
        }
    }

}

3.  Заходим в templates\Default Открыть файл main.tpl
ищем:

<script type="text/javascript" src="{theme}/js/reg.js"></script>

Ниже ставим

<script type="text/javascript" src="{theme}/js/masonry.pkgd.js"></script>

4. Заходим в system\classes Открыть там файл wall.php
Ищем:

$attach_result .= '<div class="clear"></div>';

Ниже ставим

$masonry_array_images = array();

Ищем:

//Фото со стены юзера
                                        } elseif($attach_type[0] == 'photo_u'){
                                                if($row_wall['tell_uid']) $attauthor_user_id = $row_wall['tell_uid'];
                                                else $attauthor_user_id = $row_wall['author_user_id'];

                                                if($attach_type[1] == 'attach' AND file_exists(ROOT_DIR."/uploads/attach/{$attauthor_user_id}/c_{$attach_type[2]}")){

                                                        if($cnt_attach == 1)
                                                       
                                                                $attach_result .= "<div class="page_photo cursor_pointer page_num{$row_wall['id']}" onClick="groups.wall_photo_view('{$row_wall['id']}', '{$attauthor_user_id}', '{$attach_type[1]}', '{$cnt_attach}', 'photo_u')"><img id="photo_wall_{$row_wall['id']}_{$cnt_attach}" src="/uploads/attach/{$attauthor_user_id}/{$attach_type[2]}" align="left" /></div>";

                                                        else
                                                               
                                                                $attach_result .= "<img id="photo_wall_{$row_wall['id']}_{$cnt_attach}" src="/uploads/attach/{$attauthor_user_id}/c_{$attach_type[2]}" style="margin-top:3px;margin-right:3px" align="left" onClick="groups.wall_photo_view('{$row_wall['id']}', '', '{$attach_type[1]}', '{$cnt_attach}')" class="cursor_pointer page_num{$row_wall['id']}" height="{$rodImHeigh}" />";
                                                               
                                                       
                                                        $cnt_attach++;

                                                       
                                                } elseif(file_exists(ROOT_DIR."/uploads/users/{$attauthor_user_id}/albums/{$attach_type[2]}/c_{$attach_type[1]}")){
                                               
                                                        if($cnt_attach < 2)
                                                                $attach_result .= "<div class="page_photo cursor_pointer page_num{$row_wall['id']}" onClick="groups.wall_photo_view('{$row_wall['id']}', '{$attauthor_user_id}', '{$attach_type[1]}', '{$cnt_attach}', 'photo_u')"><img id="photo_wall_{$row_wall['id']}_{$cnt_attach}" src="/uploads/users/{$attauthor_user_id}/albums/{$attach_type[2]}/{$attach_type[1]}" align="left" /></div>";
                                                        else
                                                                $attach_result .= "<img id="photo_wall_{$row_wall['id']}_{$cnt_attach}" src="/uploads/users/{$attauthor_user_id}/albums/{$attach_type[2]}/c_{$attach_type[1]}" style="margin-top:3px;margin-right:3px" align="left" onClick="groups.wall_photo_view('{$row_wall['id']}', '{$row_wall['tell_uid']}', '{$attach_type[1]}', '{$cnt_attach}')" class="cursor_pointer page_num{$row_wall['id']}" />";
                                                               
                                                        $cnt_attach++;
                                                }
                                               
                                                $resLinkTitle = '';
Заменить на эта

//Фото со стены юзера
                                        } elseif($attach_type[0] == 'photo_u'){
                                                if($row_wall['tell_uid']) $attauthor_user_id = $row_wall['tell_uid'];
                                                else $attauthor_user_id = $row_wall['author_user_id'];

                                               
                                                $masonry_array_images[] = $config['home_url']."uploads/attach/{$attauthor_user_id}/c_{$attach_type[2]}";
                                               
                                               
                                                if($attach_type[1] == 'attach' AND file_exists(ROOT_DIR."/uploads/attach/{$attauthor_user_id}/c_{$attach_type[2]}")){

                                                        if($cnt_attach == 1)
                                                       
                                                                $attach_result .= "<div class="profile_wall_attach_photo cursor_pointer page_num{$row_wall['id']}" onClick="groups.wall_photo_view('{$row_wall['id']}', '{$attauthor_user_id}', '{$attach_type[1]}', '{$cnt_attach}', 'photo_u')"><img id="photo_wall_{$row_wall['id']}_{$cnt_attach}" src="/uploads/attach/{$attauthor_user_id}/{$attach_type[2]}" align="left" /></div>";

                                                        else
                                                               
                                                                $attach_result .= "<img id="photo_wall_{$row_wall['id']}_{$cnt_attach}" src="/uploads/attach/{$attauthor_user_id}/c_{$attach_type[2]}" style="margin-top:3px;margin-right:3px" align="left" onClick="groups.wall_photo_view('{$row_wall['id']}', '', '{$attach_type[1]}', '{$cnt_attach}')" class="cursor_pointer page_num{$row_wall['id']}" height="{$rodImHeigh}" />";
                                                               
                                                       
                                                        $cnt_attach++;

                                                       
                                                } elseif(file_exists(ROOT_DIR."/uploads/users/{$attauthor_user_id}/albums/{$attach_type[2]}/c_{$attach_type[1]}")){
                                               
                                                        if($cnt_attach < 2)
                                                                $attach_result .= "<div class="profile_wall_attach_photo cursor_pointer page_num{$row_wall['id']}" onClick="groups.wall_photo_view('{$row_wall['id']}', '{$attauthor_user_id}', '{$attach_type[1]}', '{$cnt_attach}', 'photo_u')"><img id="photo_wall_{$row_wall['id']}_{$cnt_attach}" src="/uploads/users/{$attauthor_user_id}/albums/{$attach_type[2]}/{$attach_type[1]}" align="left" /></div>";
                                                        else
                                                                $attach_result .= "<img id="photo_wall_{$row_wall['id']}_{$cnt_attach}" src="/uploads/users/{$attauthor_user_id}/albums/{$attach_type[2]}/c_{$attach_type[1]}" style="margin-top:3px;margin-right:3px" align="left" onClick="groups.wall_photo_view('{$row_wall['id']}', '{$row_wall['tell_uid']}', '{$attach_type[1]}', '{$cnt_attach}')" class="cursor_pointer page_num{$row_wall['id']}" />";
                                                               
                                                        $cnt_attach++;
                                                }
                                               
                                                $resLinkTitle = '';

автор неизвестен

134700x7bb7upnn4tpj8j3.png

[Модуль] вывод блоков виде кирпичной кладки.rar

Ссылка на комментарий
Поделиться на другие сайты

Присоединяйтесь к обсуждению

Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.
Примечание: Ваш пост будет проверен модератором, прежде чем станет видимым.

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Вставить как обычный текст

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

Загрузка...
×
×
  • Создать...