News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Tagging System For Topics

Started by SMFHacks.com Team, December 19, 2006, 10:59:20 AM

Previous topic - Next topic

vbgamer45

There is no permission that shows if tags are visible or not.
Only permissions are add tags, remove tags, admin to manage tags.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

pocttopus

There is a tags in the main menu and also guests can add tags.
How can I disable these options?
http://mkreef.com

vbgamer45

Tags in the main menu do you want to remove for everyone? you would remove the menu entry from sources/subs.php

Guests shouldn't be able to add tags unless they have permission. Did you try as a guest to add a tag?
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

pocttopus

I want to remove tags from the main menu only for guest's, not for everyone. Members are allowed to use tags in menu. Hpw can I solve this issue?
I had disabled adding tags for guest's and that's fine.

vbgamer45

You would need to alter menu item code in sources/subs.php an add a line that checks if the user is not guest  in the permission property
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

epik


vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

njtweb

Is this a tagging system exclusive to inside the website only. or also external on the web for SEO purposes?

vbgamer45

Just on the forum. just adds tags to topics. Zero SEO benefit it is more for easy of user navigation for users to find related topics.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

njtweb

Quote from: vbgamer45 on May 22, 2019, 12:53:58 PM
Just on the forum. just adds tags to topics. Zero SEO benefit it is more for easy of user navigation for users to find related topics.

Thank you for the explanation. Very much appreciated.

Mick.

Hey bruh, do you have a block for popular tags laying around?

vbgamer45

I have this from ezportal


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

// Pass all the parematers
// Show latest Tags
// 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,t.tag AS tag
  ORDER BY l.ID DESC 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
}
}

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


echo '</div>';
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Mick.

@vbgamer Thanx bro, i did figured it out. Also, I tested your code and it returned with "Function name must be a string" error. Just a heads up.

Arantor

Depending on the portal it might need global $smcFunc; in the block too. Not all portals work the same way.

Mick.

Here's mine. Just need to dress it up with some sweet css.


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' => 50)
);

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

Mick.

Alright bro, Im trying to figure out to display either random or popular tags. As it is, it's showing the last tags.

Any ideas?

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

// 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 l.ID DESC 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'] .= '<i class="fas fa-circle"></i> <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
FROM ({db_prefix}tags_log as l,{db_prefix}boards AS b, {db_prefix}topics as t, {db_prefix}messages as m)
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'],
);
}
$smcFunc['db_free_result']($dbresult);

echo '

<br />

<div class="mod-intro">
  <div class="wrapper">
    <h3>Our Most Popular Tags</h3>
      <div class="mods">';
                if (isset($context['poptags']))
          echo $context['poptags'];
           echo'
      </div>
  </div>
</div>';


tarantula901

Do you have a solution to my problem?

'sitetable.t.tag' isn't in GROUP BY
Dosya: /sites/httpdocs/Sources/Tags2.php
Satır: 119

// 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
  [color=red]ORDER BY COUNT(l.ID_TAG) DESC, RAND() LIMIT " .  $modSettings['smftags_set_cloud_tags_to_show']);[/color]



I have used smf version 2.1 rc 2

Php version: 5.5 or 5.6

vbgamer45

You would have to change
GROUP BY l.ID_TAG
To
GROUP BY l.ID_TAG, t.tag AS tag
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

tarantula901

Quote from: vbgamer45 on December 04, 2019, 11:35:15 AM
You would have to change
GROUP BY l.ID_TAG
To
GROUP BY l.ID_TAG, t.tag AS tag

She gave this warning

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AS tag
ORDER BY COUNT(l.ID_TAG) DESC, RAND() LIMIT 5' at line 4

vbgamer45

Sorry was tired change it to
GROUP BY l.ID_TAG, t.tag
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Advertisement: