форум vBSupport.ru > В помощь веб-мастеру > Общие вопросы сайтостроения
  • »
VBsupport перешел с домена .ORG на родной .RU Ура! Пожалуйста, обновите свои закладки - VBsupport.ru
 
 
 
 
Diamant
Знаток
 
Diamant's Avatar
Default Нужна помощь в написании модуля
0

На форуме стоит следующий хак - http://vbsupport.ru/forum/showthread.php?t=44793
В одном из его модулей идет обращение к php скрипту. Выполняется какая-то функция и модуль получает данные. Потом он эти данные регистрирует как переменные и их можно юзать в шаблоне. Все эти данные используются в posbit_legacy

Код этого модуля (можно не читать):
Code:
global $vbulletin;
if ($vbulletin->options['sc_thumbs_onoff'] AND $vbulletin->options['sc_thumbs_option_post']) {
  if (THIS_SCRIPT == 'showthread' OR THIS_SCRIPT == 'showpost') {
    require_once(DIR . '/includes/functions_sc_thumbs.php'); 
    global $ids;
      $contenttype = 'post';
      $contentid = $post['postid'];
        $thumbs = fetch_thumbs($this->post['postid'], $ids, 'post', 'postid');
        $can_thumb = can_thumb_check($this->post, 'post', false, $thread['firstpostid'], $thread['forumid']);
            $type = thumbed_already_check($this->post, 'post', 'postid');
            $list = fetch_thumbers_bit($thumbs);
            $amount_unformatted = $list['users_plus_num'] - $list['users_minus_num'];      
            $amount = vb_number_format($amount_unformatted);

            $templater = vB_Template::create('sc_thumbs_box');         
              $templater->register('contenttype', $contenttype);
              $templater->register('contentid', $contentid);
              $templater->register('can_thumb', $can_thumb);
              $templater->register('type', $type);
              $templater->register('list', $list);
              $templater->register('amount', $amount);           
            $box['post_thumbs_box'] .= $templater->render();
            vB_Template::preRegister('postbit_legacy', $box);
            vB_Template::preRegister('postbit', $box);    
  }  
}

if ($vbulletin->options['sc_thumbs_onoff'] AND $vbulletin->options['sc_thumbs_option_nodecomment']) {
  if (THIS_SCRIPT == 'vbcms') {
    require_once(DIR . '/includes/functions_sc_thumbs.php'); 
    global $posts, $chk;
    if(!$chk) {$chk = 1;}
    if ($chk == 1) {$fetch_again = true;}else {$fetch_again = false;}      
      $contenttype = 'post';
      $contentid = $post['postid'];
        $thumbs = fetch_thumbs($this->post['postid'], $posts, 'post', 'postid', $fetch_again);
        $can_thumb = can_thumb_check($this->post, 'post', false);
            $type = thumbed_already_check($this->post, 'post', 'postid');
            $list = fetch_thumbers_bit($thumbs);
            $amount_unformatted = $list['users_plus_num'] - $list['users_minus_num'];      
            $amount = vb_number_format($amount_unformatted);

            $templater = vB_Template::create('sc_thumbs_box');         
              $templater->register('contenttype', $contenttype);
              $templater->register('contentid', $contentid);
              $templater->register('can_thumb', $can_thumb);
              $templater->register('type', $type);
              $templater->register('list', $list);
              $templater->register('amount', $amount);           
            $box['post_thumbs_box'] .= $templater->render();
            vB_Template::preRegister('vbcms_postbit_legacy', $box);
            vB_Template::preRegister('vbcms_postbit', $box);
   $chk++;          
  }
}

if (THIS_SCRIPT != 'vbcms') {
  if ($vbulletin->options['sc_thumbs_onoff'] AND $vbulletin->options['sc_thumbs_postbit_stats']) {
      $post['sc_thumbs_up_received'] = vb_number_format($post['sc_thumbs_up_received']);
      $post['sc_thumbs_down_received'] = vb_number_format($post['sc_thumbs_down_received']);
      $post['sc_thumbs_up_gave'] = vb_number_format($post['sc_thumbs_up_gave']);
      $post['sc_thumbs_down_gave'] = vb_number_format($post['sc_thumbs_down_gave']);
      
      $templater = vB_Template::create('sc_thumbs_postbit_info');
      $templater->register('post', $post);
      $template_hook['postbit_userinfo_right_after_posts'] .= $templater->render(); 
  }
}
Моя цель визуально (источник - MaulTalk):



Моя цель технически: мне нужно переменную amount (количество баллов у сообщения) передать в шаблон forumbit (отображение раздела), чтобы вывести возле каждой темы оценку ее первого поста.

Я в этом деле новичек, еще мало разбираюсь. Набросал следующий код:
Code:
global $vbulletin;
if ($vbulletin->options['sc_thumbs_onoff']) {
  if (THIS_SCRIPT == 'forumdisplay') {
    require_once(DIR . '/includes/functions_sc_thumbs.php'); 
    global $ids;
      $contenttype = 'post';
      $contentid = $post['postid'];
        $thumbs = fetch_thumbs($this->post['postid'], $ids, 'post', 'postid');
        $can_thumb = can_thumb_check($this->post, 'post', false, $thread['firstpostid'], $thread['forumid']);
            $list = fetch_thumbers_bit($thumbs);
            $amount_unformatted = $list['users_plus_num'] - $list['users_minus_num'];      
            $amount = vb_number_format($amount_unformatted);
            $templater = vB_Template::create('sc_thumbs_box');                   
            $box['post_thumbs_box'] .= $templater->render();
vB_Template::preRegister('forumbit',array('amount' => $amount));    
  }  
}
Знаю, что из ниоткуда не берется переменная айди поста, но это другая история.

Место выполнения - forumdisplay_start. После его активации, при переходе в раздел, выдает ошибку (Удаленный сервер или файл не найден), при этом остальные части форума работают. Что я делаю не так?
Bot
Yandex Bot Yandex Bot is online now
 
Join Date: 05.05.2005
Реклама на форуме А что у нас тут интересного? =)
 
 
mindframe
Специалист
 
mindframe's Avatar
Default
0

Бери ID первого поста темы, выводи рейтинг темы, 1 запрос в общем, правда с джоинами.
А то что ты кашу городишь, не нужно оно тебе.
 
 
Diamant
Знаток
 
Diamant's Avatar
Default
0

Quote:
Originally Posted by mindframe View Post
Бери ID первого поста темы, выводи рейтинг темы, 1 запрос в общем, правда с джоинами.
А то что ты кашу городишь, не нужно оно тебе.
Quote:
Originally Posted by Diamant View Post
Я в этом деле новичек, еще мало разбираюсь.
Какая переменная отвечает за ID первого поста? Как именно выводить?
 
 
mindframe
Специалист
 
mindframe's Avatar
Default
2

Quote:
Originally Posted by Diamant View Post
Какая переменная отвечает за ID первого поста? Как именно выводить?
Хранится в таблице thread, поле firstpostid, рейтинг поста хранится в таблице sc_thumbs_post, просто делай запрос к sc_thumbs_post и WHERE postid = $firstpostid.
Я могу написать код, это не сложно, просто попробуй сам разобраться, поверь, это интересно, возможно поначалу сложно, но у тебя под рукой как пример куча хаков, просто ковыряй и смотри.
 
 
Diamant
Знаток
 
Diamant's Avatar
Default
0

Quote:
Originally Posted by mindframe View Post
Хранится в таблице thread, поле firstpostid, рейтинг поста хранится в таблице sc_thumbs_post, просто делай запрос к sc_thumbs_post и WHERE postid = $firstpostid.
Я могу написать код, это не сложно, просто попробуй сам разобраться, поверь, это интересно, возможно поначалу сложно, но у тебя под рукой как пример куча хаков, просто ковыряй и смотри.
Дайте пример того, как достать из БД этот firstpostid. Тогда я буду по аналогии делать и научусь.

Diamant добавил 02.06.2013 в 00:06
Вот что набросал для получения firstpostid:

Code:
$point = $vbulletin->db->query_read("SELECT * FROM `".TABLE_PREFIX."thread` WHERE `threadid`=123");
vB_Template::preRegister('threadbit',array('point' => $point));
Вместо 123 нужно поставить айди темы. Откуда брать ее переменную?

Last edited by Diamant : 06-02-2013 at 12:06 AM. Reason: Добавлено сообщение
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT +4. The time now is 03:29 AM.


Powered by vBulletin® Version 3.6.0
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Loading...