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

[Модуль] мне нравится в комментариях


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

1 заходим в templates\Default\wall открыть там файл record.tpl
ишем там

<div class="clear"></div>
</div>[/comment]
[comment-form]<div class="wall_fast_opened_form" id="fast_form">

выше ставим

<div class="public_likes_user_block no_display" id="public_likes_user_block{rec-id}" onMouseOver="groups.wall_like_users_five('{rec-id}')" onMouseOut="groups.wall_like_users_five_hide('{rec-id}')">
   <div onClick="wall.all_liked_users('{rec-id}', '', '{likes}')">Понравилось {likes-text}</div>
   <div class="public_wall_likes_hidden">
    <div class="public_wall_likes_hidden2">
     <a href="/id{viewer-id}" id="like_user{viewer-id}_{rec-id}" class="no_display" onClick="Page.Go(this.href); return false"><img src="{viewer-ava}" width="32" /></a>
     <div id="likes_users{rec-id}"></div>
    </div>
   </div>
   <div class="public_like_strelka"></div>
  </div>
  <input type="hidden" id="update_like{rec-id}" value="0" />
  <div class="fl_r public_wall_like cursor_pointer" onClick="{like-js-function}" onMouseOver="groups.wall_like_users_five('{rec-id}', 'uPages')" onMouseOut="groups.wall_like_users_five_hide('{rec-id}')" id="wall_like_link{rec-id}">
   <div class="fl_l" id="wall_like_active">Мне нравится</div>
   <div class="public_wall_like_no {yes-like}" id="wall_active_ic{rec-id}"></div>
   <b id="wall_like_cnt{rec-id}" class="{yes-like-color}">{likes}</b>
  </div>
  
заходим в templates\Default\wall открыть там файл one_record.tpl
ишем там

<div class="clear"></div>
</div>[/comment]
[comment-form]<div class="wall_fast_opened_form" id="fast_form">

выше ставим

<div class="public_likes_user_block no_display" id="public_likes_user_block{rec-id}" onMouseOver="groups.wall_like_users_five('{rec-id}')" onMouseOut="groups.wall_like_users_five_hide('{rec-id}')">
   <div onClick="wall.all_liked_users('{rec-id}', '', '{likes}')">Понравилось {likes-text}</div>
   <div class="public_wall_likes_hidden">
    <div class="public_wall_likes_hidden2">
     <a href="/id{viewer-id}" id="like_user{viewer-id}_{rec-id}" class="no_display" onClick="Page.Go(this.href); return false"><img src="{viewer-ava}" width="32" /></a>
     <div id="likes_users{rec-id}"></div>
    </div>
   </div>
   <div class="public_like_strelka"></div>
  </div>
  <input type="hidden" id="update_like{rec-id}" value="0" />
  <div class="fl_r public_wall_like cursor_pointer" onClick="{like-js-function}" onMouseOver="groups.wall_like_users_five('{rec-id}', 'uPages')" onMouseOut="groups.wall_like_users_five_hide('{rec-id}')" id="wall_like_link{rec-id}">
   <div class="fl_l" id="wall_like_active">Мне нравится</div>
   <div class="public_wall_like_no {yes-like}" id="wall_active_ic{rec-id}"></div>
   <b id="wall_like_cnt{rec-id}" class="{yes-like-color}">{likes}</b>
  </div>
  

заходим в system/classes/wall.php
ишем там

//Помещаем все комменты в id wall_fast_block_{id} это для JS
                        $tpl->result[$this->compile] .= '<div id="wall_fast_block_'.$fast_comm_id.'">';
                       
                        //Загружаем кнопку "Показать N запсии" если их больше 3
                        if($record_fasts_num > 3){
                                $tpl->set('{gram-record-all-comm}', gram_record(($record_fasts_num-3), 'prev').' '.($record_fasts_num-3).' '.gram_record(($record_fasts_num-3), 'comments'));
                                $tpl->set('[all-comm]', '');
                                $tpl->set('[/all-comm]', '');
                                $tpl->set('{rec-id}', $fast_comm_id);
                                $tpl->set('{author-id}', $for_user_id);
                                $tpl->set('[wall-func]', '');
                                $tpl->set('[/wall-func]', '');
                                $tpl->set_block("'\\[groups\\](.*?)\\[/groups\\]'si","");
                                $tpl->set_block("'\\[record\\](.*?)\\[/record\\]'si","");
                                $tpl->set_block("'\\[comment-form\\](.*?)\\[/comment-form\\]'si","");
                                $tpl->set_block("'\\[comment\\](.*?)\\[/comment\\]'si","");
                                $tpl->compile($this->comm_compile);
                        } else
                                $tpl->set_block("'\\[all-comm\\](.*?)\\[/all-comm\\]'si","");
                               
                        //Сообственно выводим комменты
                        foreach($this->comm_query as $row_comments){
                               
                                $tpl->set('{name}', $row_comments['user_search_pref']);
                                if($row_comments['user_photo'])
                                        $tpl->set('{ava}', '/uploads/users/'.$row_comments['author_user_id'].'/50_'.$row_comments['user_photo']);
                                else
                                        $tpl->set('{ava}', '{theme}/images/no_ava_50.png');

                                $tpl->set('{rec-id}', $fast_comm_id);
                                $tpl->set('{comm-id}', $row_comments['id']);
                                $tpl->set('{user-id}', $row_comments['author_user_id']);
                               
                                $expBR2 = explode('<br />', $row_comments['text']);
                                $textLength2 = count($expBR2);
                                $strTXT2 = strlen($row_comments['text']);
                                if($textLength2 > 6 OR $strTXT2 > 470)
                                        $row_comments['text'] = '<div class="wall_strlen" id="hide_wall_rec'.$row_comments['id'].'" style="max-height:102px"">'.$row_comments['text'].'</div><div class="wall_strlen_full" onMouseDown="wall.FullText('.$row_comments['id'].', this.id)" id="hide_wall_rec_lnk'.$row_comments['id'].'">Показать полностью..</div>';
                                               
                                if($row_comments['attach']){
                               
                                $attcahed = attached($row_comments);
                                if($attcahed)
                                        $row_comments['text'] = preg_replace('`(http(?:s)?://\w+[^\s\[\]\<]+)`i', '<a href="/away.php?url=$1" target="_blank">$1</a>', $row_comments['text']).$attcahed;
                                else
                                        $row_comments['text'] = preg_replace('`(http(?:s)?://\w+[^\s\[\]\<]+)`i', '<a href="/away.php?url=$1" target="_blank">$1</a>', $row_comments['text']);
                        } else
                                $row_comments['text'] = preg_replace('`(http(?:s)?://\w+[^\s\[\]\<]+)`i', '<a href="/away.php?url=$1" target="_blank">$1</a>', $row_comments['text']);
                               
                        $resLinkTitle = '';                               
       
                                $tpl->set('{text}', stripslashes($row_comments['text']));
                               
                                megaDate($row_comments['add_date']);
                               
                                if(!$id)
                                        $id = $for_user_id;
                                       
                                if($user_id == $row_comments['author_user_id'] || $user_id == $id){
                                        $tpl->set('[owner]', '');
                                        $tpl->set('[/owner]', '');
                                } else
                                        $tpl->set_block("'\\[owner\\](.*?)\\[/owner\\]'si","");
                                       
                                if($user_id == $row_comments['author_user_id'])
                               
                                        $tpl->set_block("'\\[not-owner\\](.*?)\\[/not-owner\\]'si","");
                                       
                                else {

                                        $tpl->set('[not-owner]', '');
                                        $tpl->set('[/not-owner]', '');
                                       
                                }
                               
                                $tpl->set('[comment]', '');
                                $tpl->set('[/comment]', '');
                                $tpl->set('[wall-func]', '');
                                $tpl->set('[/wall-func]', '');
                                $tpl->set_block("'\\[groups\\](.*?)\\[/groups\\]'si","");
                                $tpl->set_block("'\\[record\\](.*?)\\[/record\\]'si","");
                                $tpl->set_block("'\\[comment-form\\](.*?)\\[/comment-form\\]'si","");
                                $tpl->set_block("'\\[all-comm\\](.*?)\\[/all-comm\\]'si","");
                               
                               
2                        МЕЖДУ ВОТ ЭТИМ СТАВИМ

                                $tpl->compile($this->comm_compile);
                        }
                               
                               
ЭТА

//Мне нравится
                        if(stripos($row_comments['likes_users'], "u{$user_id}|") !== false){
                                $tpl->set('{yes-like}', 'public_wall_like_yes');
                                $tpl->set('{yes-like-color}', 'public_wall_like_yes_color');
                                $tpl->set('{like-js-function}', 'groups.wall_remove_like('.$row_comments['id'].', '.$user_id.', \'uPages\')');
                        } else {
                                $tpl->set('{yes-like}', '');
                                $tpl->set('{yes-like-color}', '');
                                $tpl->set('{like-js-function}', 'groups.wall_add_like('.$row_comments['id'].', '.$user_id.', \'uPages\')');
                        }

                        if($row_comments['likes_num']){
                                $tpl->set('{likes}', $row_comments['likes_num']);
                                $tpl->set('{likes-text}', '<span id="like_text_num'.$row_comments['id'].'">'.$row_comments['likes_num'].'</span> '.gram_record($row_comments['likes_num'], 'like'));
                        } else {
                                $tpl->set('{likes}', '');
                                $tpl->set('{likes-text}', '<span id="like_text_num'.$row_comments['id'].'">0</span> человеку');
                        }

                    $tpl->set('{rec-id}', $row_comments['id']);

                        //Выводим информцию о том кто смотрит страницу для себя
                        $tpl->set('{viewer-id}', $user_id);
                        if($user_info['user_photo'])
                                $tpl->set('{viewer-ava}', '/uploads/users/'.$user_id.'/50_'.$user_info['user_photo']);
                        else
                                $tpl->set('{viewer-ava}', '{theme}/images/no_ava_50.png');
                               
ТАМЖЕ ИШЕМ

//Помещаем все комменты в id wall_fast_block_{id} это для JS
                        $tpl->result[$this->compile] .= '<div id="wall_fast_block_'.$row_wall['id'].'">';
                               
                        //Если есть комменты к записи, то открываем форму ответа уже в развернутом виде и выводим комменты к записи
                        if($user_privacy['val_wall3'] == 1 OR $user_privacy['val_wall3'] == 2 AND $check_friend OR $user_id == $id){
                                if($row_wall['fasts_num']){
                                       
                                        if($row_wall['fasts_num'] > 3)
                                                $comments_limit = $row_wall['fasts_num']-3;
                                        else
                                                $comments_limit = 0;
                                       
                                        $sql_comments = $db->super_query("SELECT tb1.id, attach, tell_uid,author_user_id, text, add_date, tb2.user_photo, user_search_pref FROM `".PREFIX."_wall` tb1, `".PREFIX."_users` tb2 WHERE tb1.author_user_id = tb2.user_id AND tb1.fast_comm_id = '{$row_wall['id']}' ORDER by `add_date` ASC LIMIT {$comments_limit}, 3", 1);

                                        //Загружаем кнопку "Показать N запсии"
                                        $tpl->set('{gram-record-all-comm}', gram_record(($row_wall['fasts_num']-3), 'prev').' '.($row_wall['fasts_num']-3).' '.gram_record(($row_wall['fasts_num']-3), 'comments'));
                                        if($row_wall['fasts_num'] < 4)
                                                $tpl->set_block("'\\[all-comm\\](.*?)\\[/all-comm\\]'si","");
                                        else {
                                                $tpl->set('{rec-id}', $row_wall['id']);
                                                $tpl->set('[all-comm]', '');
                                                $tpl->set('[/all-comm]', '');
                                        }
                                        $tpl->set('{author-id}', $id);
                                        $tpl->set_block("'\\[record\\](.*?)\\[/record\\]'si","");
                                        $tpl->set_block("'\\[comment-form\\](.*?)\\[/comment-form\\]'si","");
                                        $tpl->set_block("'\\[comment\\](.*?)\\[/comment\\]'si","");
                                        $tpl->compile($this->compile);
                               
                                        //Сообственно выводим комменты
                                        foreach($sql_comments as $row_comments){
                               
               
                                                $tpl->set('{name}', $row_comments['user_search_pref']);
                                                if($row_comments['user_photo'])
                                                        $tpl->set('{ava}', '/uploads/users/'.$row_comments['author_user_id'].'/50_'.$row_comments['user_photo']);
                                                else
                                                        $tpl->set('{ava}', '{theme}/images/no_ava_50.png');
                       
                                                $tpl->set('{rec-id}', $row_wall['id']);
                                                $tpl->set('{comm-id}', $row_comments['id']);
                                                $tpl->set('{user-id}', $row_comments['author_user_id']);
                                               
                                                $expBR2 = explode('<br />', $row_comments['text']);
                                                $textLength2 = count($expBR2);
                                                $strTXT2 = strlen($row_comments['text']);
                                                if($textLength2 > 6 OR $strTXT2 > 470)
                                                        $row_comments['text'] = '<div class="wall_strlen" id="hide_wall_rec'.$row_comments['id'].'" style="max-height:102px"">'.$row_comments['text'].'</div><div class="wall_strlen_full" onMouseDown="wall.FullText('.$row_comments['id'].', this.id)" id="hide_wall_rec_lnk'.$row_comments['id'].'">Показать полностью..</div>';
                                       
                                                //Обрабатываем ссылки
                                                $row_comments['text'] = preg_replace('`(http(?:s)?://\w+[^\s\[\]\<]+)`i', '<a href="/away.php?url=$1" target="_blank">$1</a>', $row_comments['text']);

                                                $attcahed = attached($row_comments);
                if($attcahed)
                        $row_comments['text'] = preg_replace('`(http(?:s)?://\w+[^\s\[\]\<]+)`i', '<a href="/away.php?url=$1" target="_blank">$1</a>', $row_comments['text']).$attcahed;
                else
                        $row_comments['text'] = preg_replace('`(http(?:s)?://\w+[^\s\[\]\<]+)`i', '<a href="/away.php?url=$1" target="_blank">$1</a>', $row_comments['text']);

                                               
                                                $tpl->set('{text}', stripslashes($row_comments['text']));
                                                megaDate($row_comments['add_date']);
                                                if($user_id == $row_comments['author_user_id'] || $user_id == $id){
                                                        $tpl->set('[owner]', '');
                                                        $tpl->set('[/owner]', '');
                                                } else
                                                        $tpl->set_block("'\\[owner\\](.*?)\\[/owner\\]'si","");
                                       
                                                if($user_id == $row_comments['author_user_id'])
                                               
                                                        $tpl->set_block("'\\[not-owner\\](.*?)\\[/not-owner\\]'si","");
                                                       
                                                else {

                                                        $tpl->set('[not-owner]', '');
                                                        $tpl->set('[/not-owner]', '');
                                                       
                                                }
                               
                                                $tpl->set('[comment]', '');
                                                $tpl->set('[/comment]', '');
                                                $tpl->set_block("'\\[record\\](.*?)\\[/record\\]'si","");
                                                $tpl->set_block("'\\[comment-form\\](.*?)\\[/comment-form\\]'si","");
                                                $tpl->set_block("'\\[all-comm\\](.*?)\\[/all-comm\\]'si","");
                                               
                                        МЕЖДУ ЭТИМ ВСТАВЛЯЕМ       

                                                $tpl->compile($this->compile);
                                        }
                               
                               
ЭТА

        //Мне нравится 222
                        if(stripos($row_comments['likes_users'], "u{$user_id}|") !== false){
                                $tpl->set('{yes-like}', 'public_wall_like_yes');
                                $tpl->set('{yes-like-color}', 'public_wall_like_yes_color');
                                $tpl->set('{like-js-function}', 'groups.wall_remove_like('.$row_comments['id'].', '.$user_id.', \'uPages\')');
                        } else {
                                $tpl->set('{yes-like}', '');
                                $tpl->set('{yes-like-color}', '');
                                $tpl->set('{like-js-function}', 'groups.wall_add_like('.$row_comments['id'].', '.$user_id.', \'uPages\')');
                        }

                        if($row_comments['likes_num']){
                                $tpl->set('{likes}', $row_comments['likes_num']);
                                $tpl->set('{likes-text}', '<span id="like_text_num'.$row_comments['id'].'">'.$row_comments['likes_num'].'</span> '.gram_record($row_comments['likes_num'], 'like'));
                        } else {
                                $tpl->set('{likes}', '');
                                $tpl->set('{likes-text}', '<span id="like_text_num'.$row_comments['id'].'">0</span> человеку');
                        }

                    $tpl->set('{rec-id}', $row_comments['id']);

                        //Выводим информцию о том кто смотрит страницу для себя
                        $tpl->set('{viewer-id}', $user_id);
                        if($user_info['user_photo'])
                                $tpl->set('{viewer-ava}', '/uploads/users/'.$user_id.'/50_'.$user_info['user_photo']);
                        else
                                $tpl->set('{viewer-ava}', '{theme}/images/no_ava_50.png');                       
                               
                               
                               
                               
3. В том же файле ищем запрос $sql_comments = $db->super_query и добавляем к нему tb1.likes_num, tb1.likes_users, 

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

173200ksdkeeceasxycxne.png

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

  • KirKMS изменил название на [Модуль] мне нравится в комментариях
×
×
  • Создать...