Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 12389
Latest: GhostHunting
New This Month: 6
New This Week: 1
New Today: 0
Stats
Total Posts: 40341
Total Topics: 7102
Most Online Today: 141
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 3
Guests: 39
Total: 42

Author Topic: Tagging system  (Read 3037 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: 15163
    • 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: 15163
    • 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
118943 Views
Last post March 15, 2017, 09:50:21 pm
by Web Presence Consulting
0 Replies
2856 Views
Last post July 06, 2007, 09:06:45 pm
by GenoDemoN
5 Replies
5209 Views
Last post November 09, 2007, 06:39:44 pm
by cru
0 Replies
2644 Views
Last post January 27, 2008, 10:06:34 am
by falguni1
1 Replies
2404 Views
Last post February 04, 2013, 02:06:54 pm
by SMFHacks

+- Recent Topics

Attachment images Upsidedown or Sideways by Shades
Today at 01:41:33 pm

Installing Awesome Post Ratings on non-default theme by Hatshepsut
Today at 06:54:31 am

Listings page image not showing by Shades
September 23, 2020, 03:05:06 pm

prettyurls - TroubleShooting.wiki by SMFHacks
September 22, 2020, 04:24:47 pm

Quality of images after import by SMFHacks
September 05, 2020, 10:21:44 am

How do I download gallery images? by CWVRV
August 30, 2020, 11:50:07 pm

Deleting Empty Galleries by SMFHacks
August 30, 2020, 11:43:32 am

PHP error by davejo
August 25, 2020, 07:35:13 am

Permissions to list ads and buy items by CWVRV
August 21, 2020, 05:19:45 pm

Doubt with download permissions. by Rock Lee
August 20, 2020, 08:23:24 pm

Powered by EzPortal