News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Tagging System For Topics

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

Previous topic - Next topic

vbgamer45

Quote from: karlbenson on December 28, 2006, 06:19:01 PM
gr8 mod. However during some heavy testing i gave it, it threw up an error in my error log when there are no tags and I visit the tags screen.  When there are tags, this error does not appear.

On a complete brand spanking new install of SMF 1.1.1 (no mods, no custom skins) hosted on VPS. PHP running i think is 5.1.  Hope this helps.


admin   Today at 04:12:26 PM 
86.133.78.125     6229d472c780ab62d866886d3ab22a80 
http://sdvsraw2.com/index.php?action=tags 
2: min() [<a href='function.min'>function.min</a>]: Array must contain atleast one element
File: /home/sdvsraw2/public_html/Sources/Tags.php
Line: 123

   admin   Today at 04:12:26 PM 
86.133.78.125     6229d472c780ab62d866886d3ab22a80 
http://sdvsraw2.com/index.php?action=tags 
2: max() [<a href='function.max'>function.max</a>]: Array must contain atleast one element
File: /home/sdvsraw2/public_html/Sources/Tags.php
Line: 122

   admin   Today at 04:12:19 PM 
86.133.78.125     6229d472c780ab62d866886d3ab22a80 
http://sdvsraw2.com/index.php?action=tags 
2: min() [<a href='function.min'>function.min</a>]: Array must contain atleast one element
File: /home/sdvsraw2/public_html/Sources/Tags.php
Line: 123

   admin   Today at 04:12:19 PM 
86.133.78.125     6229d472c780ab62d866886d3ab22a80 
http://sdvsraw2.com/index.php?action=tags 
2: max() [<a href='function.max'>function.max</a>]: Array must contain atleast one element
File: /home/sdvsraw2/public_html/Sources/Tags.php
Line: 122

   admin   Today at 04:12:16 PM 
86.133.78.125     6229d472c780ab62d866886d3ab22a80 
http://sdvsraw2.com/index.php?action=tags 
2: min() [<a href='function.min'>function.min</a>]: Array must contain atleast one element
File: /home/sdvsraw2/public_html/Sources/Tags.php
Line: 123

   admin   Today at 04:12:16 PM 
86.133.78.125     6229d472c780ab62d866886d3ab22a80 
http://sdvsraw2.com/index.php?action=tags 
2: max() [<a href='function.max'>function.max</a>]: Array must contain atleast one element
File: /home/sdvsraw2/public_html/Sources/Tags.php
Line: 122


Fixed
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

chinclub

I am using 1.1 RC3   Is it not compatable with that?  I tryed to download and install and kep getting:
"The package you are trying to download or install is either corrupt or not compatible with this version of SMF."

vbgamer45

Tested only on SMF 1.1 to 1.1.1 and currently will only install for those.
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

WhatsUp

History Hunters: http://historyhuntersinternational.org/
Enter: test/test
SMF and TinyPortal

Patxi

Hello,

nice mod! propably it would be nice to enhance the mod with a "TAG" BBCode.
Then it would be much easier to make "table of content" topics using the tags.

for example:

you want to create a "table of contents" for your forum:

1. SMF-mods
  1.1 Tools
  1.2 Enhancements

2. SMF-themes
  2.1 light
  2.2 dark

=> so add appropriate tag to your topics
=> in your "table of content" topic would be good to use the BBC:


1. SMF-mods
[TAG=tool]1.1 Tools[TAG]
[TAG=enhancement]1.2 Enhancements[TAG]

2. SMF-themes
[TAG=light-theme]  2.1 light[/TAG]
[TAG=dark-theme]  2.2 dark[/TAG]


the generated topic code should then look like:


...
<a href="http://www.simplemachines.org/community/index.php?action=tags;id=1" title="2 things tagged with tool">1.1Tools</a>


what do you think? does this make sense?

@ngel

Works great.

How is it possible to display an icon (placed in themes\...\images\icons\) in place of [X] ?

Thanks for any hints and tips

vbgamer45

Quote from: @ngel on January 05, 2007, 06:59:13 AM
Works great.

How is it possible to display an icon (placed in themes\...\images\icons\) in place of [X] ?

Thanks for any hints and tips

Yes you could. Check in Display.template.php that's were it adds the X for the 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

@ngel

I see the position of the [ X ] but i don't known by what to replace and which variable to be used.

Thanks for your help

nitins60

It would be cool, if you add option of searching for tags n Search function!

Patxi

Hello,

I guess after deleting a topic you don´t remove regading stuff in the "tags_log" table. or am I wrong? (I was just trying this mod). As I see in your code, you will add some more admin control over the tags in future!?

vbgamer45

That tags are not deleted from the table when a topic is deleted.
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

Patxi

#51
hi,

is it now possible or easily integrated to search via the Tag itself not the id?
e.g.

instead of
http://yourdomain/index.php?action=tags;id=123
do it like
http://yourdomain/index.php?action=tags;tag=NameOfTagAsText

with the same result-page.
so it would be easier to use it in posts as direct links. (sorry abou my english)




okay, I looked into the "Tags.php" and tried a little bit.

After
if (isset($_REQUEST['id']))
{
// Show the tag results for that tag
$id = (int) $_REQUEST['id'];

// Find Tag Name
$dbresult = db_query("SELECT tag FROM {$db_prefix}tags WHERE ID_TAG = $id LIMIT 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($dbresult);
mysql_free_result($dbresult);

$context['tag_search'] = $row['tag'];
$context['page_title'] = $mbname . ' - ' . $txt['smftags_resultsfor'] . $context['tag_search'];
// Find Results
$dbresult = db_query("
SELECT t.numReplies,t.numViews,m.ID_MEMBER,m.posterName,m.subject,m.ID_TOPIC,m.posterTime, 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 l.ID_TAG = $id AND b.ID_BOARD = t.ID_BOARD AND l.ID_TOPIC = t.ID_TOPIC AND t.ID_FIRST_MSG = m.ID_MSG AND " . $user_info['query_see_board'], __FILE__, __LINE__);

$context['tags_topics'] = array();
while ($row = mysql_fetch_assoc($dbresult))
{
$context['tags_topics'][] = array(
'ID_MEMBER' => $row['ID_MEMBER'],
'posterName' => $row['posterName'],
'subject' => $row['subject'],
'ID_TOPIC' => $row['ID_TOPIC'],
'posterTime' => $row['posterTime'],
'numViews' => $row['numViews'],
'numReplies' => $row['numReplies'],

);
}
mysql_free_result($dbresult);


$context['sub_template']  = 'results';

}


add

elseif (isset($_REQUEST['tag']))
{
// Show the tag results for that tag
$context['tag_search'] = $_REQUEST['tag'];

// Find Tag Name

$context['page_title'] = $mbname . ' - ' . $txt['smftags_resultsfor'] . $context['tag_search'];
// Find Results
$dbresult = db_query("
SELECT t.numReplies,t.numViews,m.ID_MEMBER,m.posterName,m.subject,m.ID_TOPIC,m.posterTime, 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
  JOIN {$db_prefix}tags AS TA ON (TA.ID_TAG = l.ID_TAG)
WHERE TA.tag = '" . $context['tag_search'] . "' AND b.ID_BOARD = t.ID_BOARD AND l.ID_TOPIC = t.ID_TOPIC AND t.ID_FIRST_MSG = m.ID_MSG AND " . $user_info['query_see_board'], __FILE__, __LINE__);

$context['tags_topics'] = array();
while ($row = mysql_fetch_assoc($dbresult))
{
$context['tags_topics'][] = array(
'ID_MEMBER' => $row['ID_MEMBER'],
'posterName' => $row['posterName'],
'subject' => $row['subject'],
'ID_TOPIC' => $row['ID_TOPIC'],
'posterTime' => $row['posterTime'],
'numViews' => $row['numViews'],
'numReplies' => $row['numReplies'],

);
}
mysql_free_result($dbresult);


$context['sub_template']  = 'results';
}


and you can use the tag function directly from a link:

http://yourdomain/index.php?action=tags;tag=OneTagText

but I´m no php programmer. nether than mysql.

=> so propably this is a security risk for sql injection!? how can I fix this?
=> does this make problems if wrong tags are used?

Thanks for help,
Patxi

vbgamer45

Yeah that would lead to an injection
find

$context['tag_search'] = $_REQUEST['tag'];

Change to

$context['tag_search'] = htmlspecialchars($_REQUEST['tag'],ENT_QUOTES);
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

Patxi

Thanks vbgamer45 !

I just tried to add a bbcode to this system and added this code to the Subs.php in the function parse_bbc

array(
'tag' => 'tag',
'type' => 'unparsed_content',
'content' => '<a href="http://yourdomain/index.php?action=tags;tag=$1">$1</a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
),
array(
        'tag' => 'tag',
        'type' => 'unparsed_equals',
        'before' => '<a href="http://yourdomain/index.php?action=tags;tag=$1">',
        'after' => '</a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
      ),


It´s not very good coding. I was not quite sure how to replace the YOURDOMAIN code with a variable.

with this, you can Link to the TAG site via
[tag]YourTagText[/tag]
or
[tag=YourTagText]something other text[/tag]

vbgamer45

Replace
http://yourdomain/index.php?action=tags
With
' . $scripturl . '?action=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

Patxi

incredible! quite fast your response!

@ngel

#56
After some test, i found my solution.

If you want to replace the [ X ] with an icon/image (in my case : delete_tag.png), do this in the file "Display.Template.php" in your "Themes\[your theme]\":

replaceecho '<a href="' . $scripturl . '?action=tags;sa=deletetag;id=' . $tag['ID']  . '"><font color="#FF0000">[X]</font></a>&nbsp;';

withecho '<a href="' . $scripturl . '?action=tags;sa=deletetag;id=' . $tag['ID']  . '"><img src="' . $settings['images_url'] . '/delete_tag.png" alt="" border="0" width=12 height=13/></a>&nbsp;';

If you want to use an alternate name, use this (you need to create the $txt['smftags_deletethistag'] = "delete this tag" entry in your "Modifications.[language].php" : echo '<a href="' . $scripturl . '?action=tags;sa=deletetag;id=' . $tag['ID']  . '"><img src="' . $settings['images_url'] . '/mir_delete_tag.png" alt="' . $txt['smftags_deletethistag'] . '" border="0" width=12 height=13/></a>&nbsp;';

Your icon/image must be set in your "Themes\[your theme]\images". I resized the icon/image too.

Below, the result ;-)

Slack

Great mod - thank you very much.

We've been playing around and we are getting some empty tags listed in the Tag Cloud page.  How do we get rid of these tags?

Is it possible to alphabatize the Tag listing in the Cloud page?  Would make it easier to track down and use.

Thanks again,
slack

vbgamer45

Empty tags hmm. You would need to find the topic that posted them and delete them from there.
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

Slack

Quote from: vbgamer45 on January 08, 2007, 07:07:35 PM
Empty tags hmm. You would need to find the topic that posted them and delete them from there.

Hmm, Well, one of our moderators deleted the posts from our Recycle bin (eg they posts are permanently gone)  :P -- so I'd have to delete them directly from the database then?

Advertisement: