SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: lazo50 on June 12, 2013, 01:22:42 PM

Title: TAG Block
Post by: lazo50 on June 12, 2013, 01:22:42 PM
Hello everyone, I could use a tag block to the portal, and I'm using the TagSystem downloaded from the official website SMF.
TNX
Title: Re: TAG Block
Post by: ccbtimewiz on June 12, 2013, 02:02:39 PM
Can you link me to the mod you're using?
Title: Re: TAG Block
Post by: lazo50 on June 12, 2013, 02:08:07 PM
TaggingSystem2.4.3
http://custom.simplemachines.org/mods/index.php?mod=579
Title: Re: TAG Block
Post by: ccbtimewiz on June 12, 2013, 03:21:54 PM
Exactly what do you want the tag block to look like? What should it do? Just display tags with links?
Title: Re: TAG Block
Post by: lazo50 on June 12, 2013, 04:15:32 PM
When you place a message I can add tags and I would like to view them as in the attached image

this is taken from EzPortal
Title: Re: TAG Block
Post by: ccbtimewiz on June 12, 2013, 04:30:49 PM
Try making a new PHP block with the following in it:

Code: [Select]
function display_tags_block()
{
// For TaggingSystem2.4.3
// System created by vbgamer45

global $txt, $smcFunc, $modSettings, $scripturl, $context, $user_info;

if (!isset($modSettings['smftags_set_cloud_tags_to_show']))
echo 'There are no tags to show...';

echo '
<div align="center">';

$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 l.ID DESC
LIMIT {int:limit}',
array(
'limit' => $modSettings['smftags_set_cloud_tags_to_show'],
)
);

$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)
{
$max_size = $modSettings['smftags_set_cloud_max_font_size_precent'];
$min_size = $modSettings['smftags_set_cloud_min_font_size_precent'];

$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));

$spread = $max_qty - $min_qty;
if (0 == $spread)
    $spread = 1;

$step = ($max_size - $min_size)/($spread);

$context['poptags'] = '';
$row_count = 0;

foreach ($tags as $key => $value)
{
$row_count++;
$size = $min_size + (($value - $min_qty) * $step);

// uncomment if you want sizes in whole %:
// $size = ceil($size);

$context['poptags'] .= '<a href="' . $scripturl . '?action=tags;tagid=' . $tags2[$key] . '" style="font-size: ' . $size . '%" title="' . $value . ' things tagged with ' . $key . '">' . $key . '</a> ';

if ($row_count > ($modSettings['smftags_set_cloud_tags_per_row'] - 1))
{
$context['poptags'] .= '<br />';
$row_count = 0;
}
}
}

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


echo '
</div>';
}

display_tags_block();
Title: Re: TAG Block
Post by: lazo50 on June 12, 2013, 04:44:34 PM
Great bullett ... I tried it and it works fine  :D
many thanks  ;D :D ;D
Title: Re: TAG Block
Post by: ccbtimewiz on June 12, 2013, 04:46:45 PM
You're welcome, glad it works okay.
SimplePortal 2.3.8 © 2008-2024, SimplePortal