Облако тегов

Автор artruslan, 29 марта 2010, 01:19:52

« назад - далее »

0 Пользователи и 1 гость просматривают эту тему.

artruslan

Можно ли сделать облако тегов как на этом форуме и какой мод ставить?


artruslan

не нашлось решения. просмотрел все темы. что-то похожее Tagging System, но не понятно как им пользоваться. перечитал все темы, пробовал вывести на главную, ничего не получилось. какая-то табличка выскакивает на главной, но там ни тегов, ни надписей, ничего. куда их добавлять тоже не понятно. отлично бы было сделать выведение этого мода только на главной, но без кнопки в пункте меню - она совсем все портит. так на этом собственно и приехали. кто может помочь разобраться? Хелп!

ksamochkin

Цитата: artruslan от 30 марта 2010, 00:57:43н пробовал вывести на главную

в файл BoardIndex.template.php перед echo '
<div id="boardindex_table">
<table class="table_list">';

вставляем

// * tag
global $context, $txt, $mbname, $scripturl, $user_info, $smcFunc,  $modSettings;

// Views that tag results and popular tags
if (isset($_REQUEST['tagid']))
{
// Show the tag results for that tag
$id = (int) $_REQUEST['tagid'];

// Find Tag Name
$dbresult = $smcFunc['db_query']('', "
SELECT
tag
FROM {db_prefix}tags
WHERE ID_TAG = $id LIMIT 1");
$row = $smcFunc['db_fetch_assoc']($dbresult);
$smcFunc['db_free_result']($dbresult);

$context['tag_search'] = $row['tag'];
$context['page_title'] = $mbname . ' - ' . $txt['smftags_resultsfor'] . $context['tag_search'];
$context['start'] = (int) $_REQUEST['start'];

$dbresult = $smcFunc['db_query']('', "
SELECT count(*) as total
FROM ({db_prefix}tags_log as l, {db_prefix}boards AS b, {db_prefix}topics as t, {db_prefix}messages as m)

WHERE l.ID_TAG = $id AND b.ID_BOARD = t.ID_BOARD AND l.ID_TOPIC = t.id_topic  AND t.approved = 1
AND t.ID_FIRST_MSG = m.ID_MSG AND " . $user_info['query_see_board'] . "
");
$totalRow = $smcFunc['db_fetch_assoc']($dbresult);
$numofrows = $totalRow['total'];

// Find Results
$dbresult = $smcFunc['db_query']('', "
SELECT t.num_replies,t.num_views,m.id_member,m.poster_name,m.subject,m.id_topic,m.poster_time, t.ID_BOARD
FROM ({db_prefix}tags_log as l, {db_prefix}boards AS b, {db_prefix}topics as t, {db_prefix}messages as m)

WHERE l.ID_TAG = $id AND b.ID_BOARD = t.ID_BOARD AND l.ID_TOPIC = t.id_topic  AND t.approved = 1
AND t.ID_FIRST_MSG = m.ID_MSG AND " . $user_info['query_see_board'] . "
ORDER BY m.ID_MSG DESC LIMIT $context[start],25 ");

$context['tags_topics'] = array();
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
$context['tags_topics'][] = array(
'id_member' => $row['id_member'],
'poster_name' => $row['poster_name'],
'subject' => $row['subject'],
'id_topic' => $row['id_topic'],
'poster_time' => $row['poster_time'],
'num_views' => $row['num_views'],
'num_replies' => $row['num_replies'],

);


}
$smcFunc['db_free_result']($dbresult);


$context['sub_template']  = 'results';

$context['page_index'] = constructPageIndex($scripturl . '?action=tags;tagid=' . $id, $_REQUEST['start'], $numofrows, 25);

}
else
{
$context['page_title'] = $mbname . ' - ' . $txt['smftags_popular'];

// Tag cloud from http://www.prism-perfect.net/archive/php-tag-cloud-tutorial/
$result = $smcFunc['db_query']('', "
SELECT
t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity
FROM {db_prefix}tags as t, {db_prefix}tags_log as l WHERE t.ID_TAG = l.ID_TAG
  GROUP BY l.ID_TAG
  ORDER BY COUNT(l.ID_TAG) DESC, RAND() LIMIT " .  $modSettings['smftags_set_cloud_tags_to_show']);

// here we loop through the results and put them into a simple array:
// $tag['thing1'] = 12;
// $tag['thing2'] = 25;
// etc. so we can use all the nifty array functions
// to calculate the font-size of each tag
$tags = array();

$tags2 = array();

while ($row = $smcFunc['db_fetch_assoc']($result))
{
    $tags[$row['tag']] = $row['quantity'];
    $tags2[$row['tag']] = $row['ID_TAG'];
}

if (count($tags2) > 0)
{
// change these font sizes if you will
$max_size = $modSettings['smftags_set_cloud_max_font_size_precent']; // max font size in %
$min_size = $modSettings['smftags_set_cloud_min_font_size_precent']; // min font size in %

// get the largest and smallest array values
$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));

// find the range of values
$spread = $max_qty - $min_qty;
if (0 == $spread)
{ // we don't want to divide by zero
    $spread = 1;
}

// determine the font-size increment
// this is the increase per tag quantity (times used)
$step = ($max_size - $min_size)/($spread);

// loop through our tag array
$context['poptags'] = '';
$row_count = 0;
foreach ($tags as $key => $value)
{
$row_count++;
    // calculate CSS font-size
    // find the $value in excess of $min_qty
    // multiply by the font-size increment ($size)
    // and add the $min_size set above
    $size = $min_size + (($value - $min_qty) * $step);
    // uncomment if you want sizes in whole %:
    // $size = ceil($size);

    // you'll need to put the link destination in place of the #
    // (assuming your tag links to some sort of details page)
    $context['poptags'] .= '<a href="' . $scripturl . '?action=tags;tagid=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
    // perhaps adjust this title attribute for the things that are tagged
   $context['poptags'] .= ' title="'.$value.' things tagged with '.$key.'"';
   $context['poptags'] .= '>'.$key.'</a> ';
   if ($row_count > ($modSettings['smftags_set_cloud_tags_per_row']-1))
   {
    $context['poptags'] .= '<br />';
    $row_count =0;
   }
    // notice the space at the end of the link
}
}


// Find Results
$dbresult = $smcFunc['db_query']('', "
SELECT DISTINCT l.ID_TOPIC, t.num_replies,t.num_views,m.id_member,
m.poster_name,m.subject,m.id_topic,m.poster_time,
t.id_board, g.tag, g.ID_TAG
FROM ({db_prefix}tags_log as l, {db_prefix}boards AS b, {db_prefix}topics as t, {db_prefix}messages as m)
  LEFT JOIN {db_prefix}tags AS g ON (l.ID_TAG = g.ID_TAG)
WHERE b.ID_BOARD = t.id_board AND l.ID_TOPIC = t.id_topic AND t.approved = 1 AND t.id_first_msg = m.id_msg AND " . $user_info['query_see_board'] . " ORDER BY l.ID DESC LIMIT 20");

$context['tags_topics'] = array();
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
$context['tags_topics'][] = array(
'id_member' => $row['id_member'],
'poster_name' => $row['poster_name'],
'subject' => $row['subject'],
'id_topic' => $row['id_topic'],
'poster_time' => $row['poster_time'],
'num_views' => $row['num_views'],
'num_replies' => $row['num_replies'],
'ID_TAG' => $row['ID_TAG'],
'tag' => $row['tag'],

);
}
$smcFunc['db_free_result']($dbresult);


}


$context['linktree'][] = array(
'url' => $scripturl . '?action=tags',
'name' => $txt['smftags_menu']
);



echo '
<table border="0" cellpadding="0" cellspacing="0" align="center" width="95%">
  <tr>
  <td align="center"  class="catbg">',$txt['smftags_popular'], '

  </td>
  </tr>
  <tr>
  <td align="center" class="windowbg2">';


  if (isset($context['poptags']))
  echo $context['poptags'];


 echo '
  </td>
  </tr>
  </table><br><br>
';
// * tag

пример можете посмотреть на http://вприкамье.рф/
только смотреть с компа а не с мобилы