collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 431
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Blocks speak! Do you have an interest in getting more blocks - or even making your own? The Blocks Board is for you!

Author Topic: Tags Block  (Read 8057 times)

0 Members and 1 Guest are viewing this topic.

Offline stikkki

  • Semi Newbie
  • *
  • Posts: 14
    • Eots Dzine
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Tags Block
« on: January 10, 2009, 01:57:18 PM »
there is a mod for SMF for creating tags -
Tagging System For Topics http://www.simplemachines.org/community/index.php?topic=135761.0

Does anyone know a way of adding these tags into a block so that the tags cloud can be displayed on the portal so that the tags are clickable to direct you to the topics

cheers

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Tags Block
« Reply #1 on: February 03, 2009, 07:13:14 AM »
For SMF 1.x:

Code: [Select]
global $db_prefix, $modSettings, $context, $scripturl;

$result = 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 " . $modSettings['smftags_set_cloud_tags_to_show'], __FILE__, __LINE__);

$tags = array();

$tags2 = array();

while ($row = mysql_fetch_array($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']; // max font size in %
$min_size = $modSettings['smftags_set_cloud_min_font_size_precent']; // min font size in %

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

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

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

$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'])
   {
    $context['poptags'] .= '<br />';
    $row_count =0;
   }
    // notice the space at the end of the link
}
}

echo $context['poptags'];

For SMF 2.x:

Code: [Select]
global $smcFunc, $scripturl, $modSettings, $context;

$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 " .  $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']; // max font size in %
$min_size = $modSettings['smftags_set_cloud_min_font_size_precent']; // min font size in %

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

$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
}
}

echo $context['poptags'];
And slowly, you come to realize... It's all as it should be...

Offline DaRKeN

  • Jr. Member
  • **
  • Posts: 50
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Tags Block
« Reply #2 on: April 22, 2010, 03:13:27 AM »
Hola. Una cosilla, porque al ingresar eso en un bloque PHP de SimplePortal me marca este error:

Error en la Base de Datos
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5
Archivo: /homepages/38/d283347434/htdocs/darken/foro/Sources/PortalBlocks.php(3444) : eval()'d code
LĂ­nea: 7


SMF: 1.1.11
SP: 2.3.2

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Tags Block
« Reply #3 on: April 22, 2010, 09:10:02 AM »
DaRKeN,
Please use the relevant International Support board.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline DaRKeN

  • Jr. Member
  • **
  • Posts: 50
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Tags Block
« Reply #4 on: April 23, 2010, 03:03:23 AM »
OMG! No me di cuenta, lo siento y muchas gracias por tu paciencia y respuesta.  :)

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Tags Block
« Reply #5 on: April 23, 2010, 03:41:23 AM »
This is an English only support board. Please use English or use the relevant International Support board.

You will not receive support in a language other than English here.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Tags Block
« Reply #6 on: April 23, 2010, 05:15:21 PM »
Nathaniel, he just said "OMG! I did not realize this. I'm sorry and thank you very much for your patience and response."

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Tags Block
« Reply #7 on: April 23, 2010, 09:18:05 PM »
Nathaniel, he just said "OMG! I did not realize this. I'm sorry and thank you very much for your patience and response."

Thanks for the translation ccb. :) Its a bit hard to tell when its in a language I don't know though. ;)
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Tags Block
« Reply #8 on: April 23, 2010, 11:07:23 PM »
Yeah I figured. Hope he finds the right support.

Offline amko_sa

  • Translator
  • *
  • Posts: 45
  • Gender: Male
    • Newsapp Portal
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Tags Block
« Reply #9 on: April 24, 2010, 08:05:34 AM »
Why when I click on any tag in tag list, takes me to the my forum page.
Can lead to a topic that contain that word?
I use smf 2 and simple portal 2.3.2.

Code: [Select]
global $smcFunc, $scripturl, $modSettings, $context;

$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 " .  $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']; // max font size in %
$min_size = $modSettings['smftags_set_cloud_min_font_size_precent']; // min font size in %

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

$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
}
}

echo $context['poptags'];
« Last Edit: April 24, 2010, 08:09:33 AM by amko_sa »

Offline kcmartz

  • Semi Newbie
  • *
  • Posts: 39
  • SMF Version: 2.0.4
  • SP Version: 2.3.5
Re: Tags Block
« Reply #10 on: June 07, 2010, 01:43:51 PM »
Nathaniel, he just said "OMG! I did not realize this. I'm sorry and thank you very much for your patience and response."

Thanks for the translation ccb. :) Its a bit hard to tell when its in a language I don't know though. ;)
http://translate.google.com will be helpful! I use it alow for one of my friends is learning japanese and I have a japanese board on my website, I use google translate to communicate, and he understands.

Offline jamiechaos

  • Newbie
  • Posts: 2
  • SMF Version: None
  • SP Version: None
Re: Tags Block
« Reply #11 on: August 09, 2010, 02:05:09 PM »
For SMF 1.x:

(snip: exactly what I was looking for)


Thank you SO MUCH.  May a thousand affectionate hedgehogs descend upon your domicile bearing gifts of gold and chocolate.

-jc