SimplePortal

Customization => Blocks and Modifications => Mod Requests => Topic started by: mobi on February 01, 2011, 01:30:14 PM

Title: Recent Posts/Topics Block - Want it to not jump to latest post
Post by: mobi on February 01, 2011, 01:30:14 PM
Hi there,

Having an issue with my Recent Posts/Topics Block. Everytime you click on a thread, it takes you to the latest post. Is there any way to change this so that it just takes you to the beginning of the thread?

Thanks in advance for your help.
Title: Re: Recent Posts/Topics Block - Want it to not jump to latest post
Post by: AngelinaBelle on February 01, 2011, 03:22:05 PM
You'll find that code at PortalBlocks.php.
 
Have fun!
Title: Re: Recent Posts/Topics Block - Want it to not jump to latest post
Post by: mobi on February 02, 2011, 03:57:19 AM
Thanks Angelina :)

Any further hints?..... :D
Title: Re: Recent Posts/Topics Block - Want it to not jump to latest post
Post by: mobi on February 02, 2011, 04:05:35 AM
Have found the code section. I think it relates to the #new parts.... what do I change them to please?

Ideally I would like any threads that contain an unread post to be bold, and once read, normal?

Cheers in advance!

Code: [Select]
<a href="', $item['href'], '">', $item['subject'], '</a> <span class="smalltext">', $txt['by'], ' ', $item['poster']['link'], $item['new'] ? '' : ' <a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '<br />[', $item['time'], ']</span><br />', empty($item['is_last']) ? '<hr />' : '';
}
elseif ($display == 'full')
{
echo '
<table class="sp_fullwidth">';

foreach ($items as $item)
echo '
<tr>
<td class="sp_recent_icon sp_center">
', sp_embed_image(empty($parameters['type']) ? 'post' : 'topic'), '
</td>
<td class="sp_recent_subject">
<a href="', $item['href'], '">', $item['subject'], '</a>
', $item['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '<br />[', $item['board']['link'], ']
</td>
<td class="sp_recent_info sp_right">
', $item['poster']['link'], '<br />', $item['time'], '
</td>
</tr>';

echo '
</table>';
}
Title: Re: Recent Posts/Topics Block - Want it to not jump to latest post
Post by: AngelinaBelle on February 02, 2011, 08:24:18 AM
One step at a time!
Have a look at the information returned by ssi_recentPosts and ssi_recentTopics.  To find that out, you'll be looking at function ssi_queryPosts. See all the stuff it returns?  That tells you you that each $item will also include $item['topic'], which is what you need to construct the URL of the first post in the topic.
 
See how ssi_queryPosts has the line:
Code: [Select]
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
This shows you how the URL is made up. Using this information, you can do
Code: [Select]
      foreach ($items as $item)  $item['href_topic'] = $scripturl . '?topic=' . $row['id_topic'] . '.0';
Then you can use $item['href_topic'] instead of $item['href']
 
Try that on for size. 
 
After you've debugged that, have a look at ssi_queryPosts again.  You'll see that you have an $item['new'] to work with, as well. You can use it to control whether some part of the output is bold or bright orange -- whatever you want.
 
Title: Re: Recent Posts/Topics Block - Want it to not jump to latest post
Post by: mobi on February 02, 2011, 09:26:34 AM
 :in-love: Thank you Angelina! You rock!

Off to go have a play!
Title: Re: Recent Posts/Topics Block - Want it to not jump to latest post
Post by: mobi on February 04, 2011, 05:13:05 AM
Argh. Sorry  :'(

Try as I mite, all I seem to be capable of doing is getting database errors :(

Please could someone give me a replace code? I would be very greatful and send virtual hugs.

I am in way over my head here....

Thank you.
Title: Re: Recent Posts/Topics Block - Want it to not jump to latest post
Post by: AngelinaBelle on February 04, 2011, 08:27:43 AM
Take out all the changes you've made while working on this.
This should not cause a database error, because should not be messing with the SQL or even with the $row it returns. I only showed you that line (involving $row) so you could see how I figured out what was being packed into that $posts array that ssi_queryPosts returns to your block, and which the block calls $items.
 
That foreach line I gave you -- it goes in Portalblocks.php, in the function definition for the block you are working on.
SimplePortal 2.3.8 © 2008-2024, SimplePortal