SimplePortal

Support => English Support => Topic started by: iain sherriff on August 09, 2015, 09:10:18 AM

Title: thread tags
Post by: iain sherriff on August 09, 2015, 09:10:18 AM
Hi all.
I am using the super Simple Thread Tags mod  http://custom.simplemachines.org/mods/index.php?mod=4034

2.0.10
SP 2.3.6


Post titles show in SP blocks with the tags in []  .............. does anyone know how to get them appearing as the mod should show them ?
Thanks
Title: Re: thread tags
Post by: [SiNaN] on August 10, 2015, 11:45:11 AM
It'd have been cool if the mod made sure it worked fine for SSI functions too. SimplePortal relies on those whenever it can, so things would look fine in blocks as well. Anyway, here are the code changes for the Top Topics block:

Sources/PortalBlocks.php

Code: (Find) [Select]
$topics = ssi_topTopics($type ? 'views' : 'replies', $limit, 'array');
Code: (Replace) [Select]
$topics = ssi_topTopics($type ? 'views' : 'replies', $limit, 'array');

foreach ($topics as $key => $topic)
{
$tag_data = makeThreadTags($topic['subject']);
$topics[$key]['subject'] = $tag_data[0];
$topics[$key]['link'] = '<a href="' . $topic['href'] . '">' . $tag_data[0] . '</a>';
$topics[$key]['tags'] = !empty($tag_data[1]) ? ' ' . $tag_data[1] : '';
}

Code: (Find) [Select]
<li class="sp_list_top">', sp_embed_image('topic'), ' ', $topic['link'], '</li>
Code: (Replace) [Select]
<li class="sp_list_top">', sp_embed_image('topic'), ' ', $topic['link'], $topic['tags'], '</li>
If you need it for the other blocks as well, then you have to edit their code in PortalBlocks.php. Basically, you have to run makeThreadTags() function on the topic subject and the resulting array has the first element as the subject and the second as the tags.
Title: Re: thread tags
Post by: iain sherriff on August 10, 2015, 12:27:25 PM
Thanks  :nervous-happy:

I'll do this later and report back
Title: Re: thread tags
Post by: iain sherriff on August 11, 2015, 08:34:19 AM
Works perfectly on Top 10 Topics block  :D

I have a Recent Posts block that I want to change as well.

I don't really understand what you said about other blocks (not your explanation......my skill! )

I found this
Code: [Select]
$type = 'ssi_recent' . (empty($parameters['type']) ? 'Posts' : 'Topics');and tried adding the first bit after that but nothing changed.

Could you post me the bits I need to change please   :-[
Title: Re: thread tags
Post by: ccbtimewiz on August 11, 2015, 05:27:31 PM
Open /Sources/PortalBlocks.php

Find:
Code: [Select]
$items = $type($limit, null, $boards, 'array');
Replace with:
Code: [Select]
$items = $type($limit, null, $boards, 'array');

foreach ($items as $key => $item)
{
$tag_data = makeThreadTags($item['subject']);
$items[$key]['subject'] = $tag_data[0];
$items[$key]['link'] = '<a href="' . $item['href'] . '">' . $tag_data[0] . '</a>';
$items[$key]['tags'] = !empty($tag_data[1]) ? ' ' . $tag_data[1] : '';
}

Find:
Code: [Select]
<a href="', $item['href'], '">', $item['subject'], '</a>
Replace with:
Code: [Select]
<a href="', $item['href'], '">', $item['subject'], '</a>' . $item['tags'] . '
Title: Re: thread tags
Post by: [SiNaN] on August 11, 2015, 05:38:01 PM
I'll do it for the recent topics/posts block too, but I won't be able to do it for others. Really, the author of that mod should handle such requests. Anyway, here are the changes:

Sources/PortalBlocks.php

Code: (Find) [Select]
$items = $type($limit, null, $boards, 'array');
Code: (Replace) [Select]
$items = $type($limit, null, $boards, 'array');

foreach ($items as $key => $item)
{
$tag_data = makeThreadTags($item['subject']);
$items[$key]['subject'] = $tag_data[0];
$items[$key]['tags'] = !empty($tag_data[1]) ? ' ' . $tag_data[1] : '';
}

Code: (Find) [Select]
<a href="', $item['href'], '">', $item['subject'], '</a>
Code: (Replace) [Select]
<a href="', $item['href'], '">', $item['subject'], '</a>', $item['tags'], '
There are two instances of the code to find for this second edit; make sure you apply them both.

Sayaka Maizono seems to have beat me to it. Just note that the $topics['tags'] should go outside the <a> tags in the second edit.
Title: Re: thread tags
Post by: ccbtimewiz on August 11, 2015, 05:48:31 PM
Ah sorry, didn't realize you were in the middle of posting.
Title: Re: thread tags
Post by: ♦ Ninja ZX-10RR ♦ on August 11, 2015, 05:51:53 PM
Not sure if either of you noticed, but your edits are slightly different...
Title: Re: thread tags
Post by: iain sherriff on August 11, 2015, 07:47:20 PM
I am very grateful to you both :thumbsup:

I now have exactly what I was looking for and I wouldn't have worked out where to put the code even though I was somewhere in the right area.

(must point out that Sayaka's version doesn't work. In [SiNaN]'s version
Code: [Select]
$item['tags'], ' is correct )
Title: Re: thread tags
Post by: ccbtimewiz on August 11, 2015, 08:10:37 PM
Lol, Sinan didn't even notice I used $topics by accident.
SimplePortal 2.3.8 © 2008-2024, SimplePortal