Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 12350
Latest: psychology-clinic-in-yazd
New This Month: 2
New This Week: 2
New Today: 1
Stats
Total Posts: 40048
Total Topics: 7051
Most Online Today: 24
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 22
Total: 22

Author Topic: Tagging system  (Read 2908 times)

0 Members and 1 Guest are viewing this topic.

Offline fatdaddy

  • Newbie
  • *
  • Posts: 38
    • View Profile
Tagging system
« on: January 03, 2015, 05:11:15 am »
Hi.
I have this installed and working on a 2.0.9 board.
I also have Tiny Portal.
I have a block that shows all the tags and reflects them in Alphabetical order as my main Tags page. The block responds to text size changes as I request.
The one thing I can't do is make the individual links in the block go to the individual tag, no matter which tag is clicked in the portal block you are taken to the main tag cloud and list of latest tags.
No one on the TP site can help.......................can you ?

thanks

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

$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 t.tag LIMIT {int:limit}',
array('limit' => 100)
);

$tags = array();
$tags2 = array();

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

$smcFunc['db_free_result']($result);

if(count($tags2) > 0)
{
// change these font sizes if you will
$max_size = 100; // max font size in %
$min_size = 100; // 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
$poptags = '';
$row_count = 1;
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)
$poptags .= '<a href="' . $scripturl . '?action=tags;id=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
// perhaps adjust this title attribute for the things that are tagged
$poptags .= ' title="'.$value.' things tagged with '.$key.'"';
$poptags .= '>'.$key.'</a> ';
               
if ($row_count > 1)
{
$poptags .= '<br />';
$row_count =1;
}
}
}
echo  $poptags;

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15029
    • View Profile
Re: Tagging system
« Reply #1 on: January 03, 2015, 08:47:10 am »
The code looks right. What is one of the links from the portal tags when clicked
Code: [Select]
$poptags .= '<a href="' . $scripturl . '?action=tags;id=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
// perhaps adjust this title attribute for the things that are tagged
$poptags .= ' title="'.$value.' things tagged with '.$key.'"';
$poptags .= '>'.$key.'</a> ';
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline fatdaddy

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Tagging system
« Reply #2 on: January 04, 2015, 03:38:39 am »
thanks.
if I click the tag in your tag cloud (which does bring up the relevant topic link)
Code: [Select]
http://dsdglobalsupport.com/index.php?action=tags;tagid=99
if i click the same tag in the portal block (which just takes me to your tag page
Code: [Select]
http://dsdglobalsupport.com/index.php?action=tags;id=99
hmm, I see the difference now !

Is there something I can change ?

edit: Yeh, you already pointed me where to look  :) thanks it works fine now  8)
« Last Edit: January 04, 2015, 03:41:29 am by fatdaddy »

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15029
    • View Profile
Re: Tagging system
« Reply #3 on: January 04, 2015, 09:22:54 am »
Glad you have it figured out!
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

 

Related Topics

  Subject / Started by Replies Last post
[Mod] Tagging System

Started by SMFHacks « 1 2 ... 7 8 » Latest Mods

105 Replies
117165 Views
Last post March 15, 2017, 09:50:21 pm
by Web Presence Consulting
0 Replies
2774 Views
Last post July 06, 2007, 09:06:45 pm
by GenoDemoN
5 Replies
5068 Views
Last post November 09, 2007, 06:39:44 pm
by cru
0 Replies
2597 Views
Last post January 27, 2008, 10:06:34 am
by falguni1
1 Replies
2287 Views
Last post February 04, 2013, 02:06:54 pm
by SMFHacks

+- Recent Topics

[Mod]Avatars Display Integration by SMFHacks
February 15, 2020, 07:30:47 pm

[Mod]BBC Message Boxes 1.0 by SMFHacks
February 15, 2020, 07:26:46 pm

[Mod]Stack Trace by live627 by SMFHacks
February 15, 2020, 07:21:33 pm

Stripe Integration by SMFHacks
February 08, 2020, 10:55:29 pm

SMF Store 4.0 Released by SMFHacks
January 26, 2020, 12:11:56 pm

Order of photos by D4611001
January 21, 2020, 12:06:36 pm

Cannot install by SMFHacks
January 18, 2020, 09:40:56 pm

Call to undefined function mysql_query() by SMFHacks
January 18, 2020, 02:06:47 pm

English British Translation file by HAL9000
January 17, 2020, 05:44:28 pm

Characters dispayed as boxes by SMFHacks
January 16, 2020, 07:21:51 am

Powered by EzPortal