News:

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

Main Menu

Need this mod for 2.0 badly! Recent posts @ top of board index

Started by ssaudio, April 11, 2008, 05:08:39 AM

Previous topic - Next topic

ssaudio

Need this mod for 2.0 badly!  Recent posts @ top of board index

Anyone working on this?  Or is it allready done?  I can't seem to find it anywhere.  Any help would be great, thanks in advance.

My site:  http://www.caraudio-forum.com [nofollow]

redone


Powerbob

It is posted everywhere that 2.0 is beta software, and as such mods are as yet few and far between.



My SMF 2.1 Beta test site; http://www.pplb.net/smf21/index.php

slinouille

Hello,

Here is what I've done.

First open file BoardIndex.template.php and find this :
Quote/* Each category in categories is made up of:
   id, href, link, name, is_collapsed (is it collapsed?), can_collapse (is it okay if it is?),
   new (is it new?), collapse_href (href to collapse/expand), collapse_image (up/down image),
   and boards. (see below.) */
   $first = true;
   foreach ($context['categories'] as $category)
   {
      echo '
   <div class="tborder" style="margin-top: ' , $first ? '0;' : '1ex;' , '' , $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'width: 100%;' : '', '">
      <div class="catbg', $category['new'] ? '2' : '', '" style="padding: 5px 5px 5px 10px;">';
      $first = false;

Just before, insert this code :
Quote

   //Show last messages
   echo '
   <br />
   <div class="tborder">
      <table border="0" width="100%" cellspacing="1" cellpadding="4">
         <tr class="titlebg">
            <td align="center" colspan="2">', $txt['last_messages'], '</td>
         </tr>
         <tr>
            <td class="windowbg" width="20" valign="middle" align="center">
               <a href="', $scripturl, '?action=recent">
                  <img src="', $settings['images_url'], '/post/xx.gif" alt="', $txt[214], '" border="0" /></a>
            </td>
            <td class="windowbg2">';
               require('SSI.php');
               ssi_recentTopics();
               echo '<br>
               <a href="', $scripturl, '?action=unread"><b>', $txt['unread_since_visit'], '</b></a>
            </td>
         </tr>
      </table>
   </div><br>';
   //End

Adapt as you want.

Secondly open file Modifications.english.php and insert :
Quote$txt['last_messages'] = "Last posted messages";

Note that by default the number of messages shown is 8. You can change that by editing the file SSI.php.
Get to function ssi_recentTopics
Set the variable $num_recent as you want.
In my case it is 10 messages, and the code looks like :
Quote// Recent topic list:   [board] Subject by Poster   Date
function ssi_recentTopics($num_recent = 10, $exclude_boards = null, $include_boards = null, $output_method = 'echo')

I hope it will help waiting for an official mod ;-)

Bye

Slin
Visit VAG-Technique.fr
Take a look to my mods

iceman~

Works like a charm slinouille ... Thanks mate.
Is there anyway we could get it left aligned and give it a header like " Recent Post "
Attaching a pic ... Hope you get what i mean.
A wise monkey never monkies with another monkey's monkey

slinouille

For the alignement, modify the line
<td class="windowbg" width="20" valign="middle" align="center">
by
<td class="windowbg" width="20" valign="middle" align="left">

For the second point, do you mean that you don't want the header?
if Yes, suppress this line
<td align="center" colspan="2">', $txt['last_messages'], '</td>

Hope it is what you want ;-)

SliN
Visit VAG-Technique.fr
Take a look to my mods

iceman~

WOW thanks for the quick reply mate .... works awesome.

What i meant was that i need a header " Recent Post " .... if you see the pic it has no header mate.
A wise monkey never monkies with another monkey's monkey

slinouille

Oops I've written something wrong in my previous answer  :-[

In fact, please don't change the both lines I told you to.

Open file SSI.php and go to function ssi_recentTopics

Search for that part of the code

$smcFunc['db_free_result']($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)


In the loop "foreach" is build the table that contains the recent post.
You can set the "alignement" you want in each columns.

Here is how my table is set
echo '
<tr>
<td align="left" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $txt['by'], ' ', $post['poster']['link'], '
', !$post['is_new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '
</td>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
</tr>';


So you have an example ;)

Concerning the header, you have to modify your "Modifications.language.php" file by adding this line
$txt['last_messages'] = "Last posted messages";
As my forum is in French, I've added it the file "Modifications.French.php"

Is it clear ?

I've added a capture of my table.

SliN
Visit VAG-Technique.fr
Take a look to my mods

iceman~

No probs Mate ... Thanks a million. Will do it now and get back to you.
A wise monkey never monkies with another monkey's monkey

iceman~

Nope not working out mate.
Would it be ok if i attach my ssi.php so that you could check it and set it right ( if its not too much of trouble ).
Thanks mate.
A wise monkey never monkies with another monkey's monkey

slinouille

Visit VAG-Technique.fr
Take a look to my mods

iceman~

Attaching it here mate ... Thanks.
A wise monkey never monkies with another monkey's monkey

ssaudio

I'm going to try this in the next hour, crossing my fingers, and thanks for the help, I owe you one.

ssaudio

Ok, I don't
Quote from: slinouille on April 12, 2008, 01:58:37 AM
Hello,

Here is what I've done.

First open file BoardIndex.template.php and find this :
Quote/* Each category in categories is made up of:
   id, href, link, name, is_collapsed (is it collapsed?), can_collapse (is it okay if it is?),
   new (is it new?), collapse_href (href to collapse/expand), collapse_image (up/down image),
   and boards. (see below.) */
   $first = true;
   foreach ($context['categories'] as $category)
   {
      echo '
   <div class="tborder" style="margin-top: ' , $first ? '0;' : '1ex;' , '' , $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'width: 100%;' : '', '">
      <div class="catbg', $category['new'] ? '2' : '', '" style="padding: 5px 5px 5px 10px;">';
      $first = false;

Just before, insert this code :
Quote

   //Show last messages
   echo '
   <br />
   <div class="tborder">
      <table border="0" width="100%" cellspacing="1" cellpadding="4">
         <tr class="titlebg">
            <td align="center" colspan="2">', $txt['last_messages'], '</td>
         </tr>
         <tr>
            <td class="windowbg" width="20" valign="middle" align="center">
               <a href="', $scripturl, '?action=recent">
                  <img src="', $settings['images_url'], '/post/xx.gif" alt="', $txt[214], '" border="0" /></a>
            </td>
            <td class="windowbg2">';
               require('SSI.php');
               ssi_recentTopics();
               echo '<br>
               <a href="', $scripturl, '?action=unread"><b>', $txt['unread_since_visit'], '</b></a>
            </td>
         </tr>
      </table>
   </div><br>';
   //End

Adapt as you want.

Secondly open file Modifications.english.php and insert :
Quote$txt['last_messages'] = "Last posted messages";

Note that by default the number of messages shown is 8. You can change that by editing the file SSI.php.
Get to function ssi_recentTopics
Set the variable $num_recent as you want.
In my case it is 10 messages, and the code looks like :
Quote// Recent topic list:   [board] Subject by Poster   Date
function ssi_recentTopics($num_recent = 10, $exclude_boards = null, $include_boards = null, $output_method = 'echo')

I hope it will help waiting for an official mod ;-)

Bye

Slin

Ok, I can't find that text that you have above in my boardindex.php file.  I put the code in the file and it shows the latest posts, but it's at the top of the page.  I changed it position on the page and it allways shows at the top.  Attached is the file.  Any help would be much appreciated.

slinouille

Hello ssaudio,

You should open file BoardIndex.template.php and NOT BoardIndex.php

That's why you don't find this part of the source code ;)

SliN
Visit VAG-Technique.fr
Take a look to my mods

riker

I was hoping recent posts would have been standard on the top (SMF 2.0) like most other forums

ssaudio

Quote from: slinouille on April 15, 2008, 02:28:38 AM
Hello ssaudio,

You should open file BoardIndex.template.php and NOT BoardIndex.php

That's why you don't find this part of the source code ;)

SliN

I've looked through all my files, I do not have that file, i'm running 2.0b3 with a different skin if that helps.

http://www.caraudio-forum.com [nofollow]

slinouille

Quote from: ssaudio on April 15, 2008, 01:46:16 PM
Quote from: slinouille on April 15, 2008, 02:28:38 AM
Hello ssaudio,

You should open file BoardIndex.template.php and NOT BoardIndex.php

That's why you don't find this part of the source code ;)

SliN

I've looked through all my files, I do not have that file, i'm running 2.0b3 with a different skin if that helps.

http://www.caraudio-forum.com
Hello

If you are running a different theme, and that you have not this file in your own theme directory, that means that the boardindex.template.php used is the one in the "Default" theme.

So you can edit the one from the "Default" directory I think and edit it as explained above.

Do that and you'll see, it will work  ;D

Bye

SliN
Visit VAG-Technique.fr
Take a look to my mods

ssaudio

Quote from: slinouille on April 16, 2008, 02:21:43 AM
Quote from: ssaudio on April 15, 2008, 01:46:16 PM
Quote from: slinouille on April 15, 2008, 02:28:38 AM
Hello ssaudio,

You should open file BoardIndex.template.php and NOT BoardIndex.php

That's why you don't find this part of the source code ;)

SliN

I've looked through all my files, I do not have that file, i'm running 2.0b3 with a different skin if that helps.

http://www.caraudio-forum.com [nofollow]
Hello

If you are running a different theme, and that you have not this file in your own theme directory, that means that the boardindex.template.php used is the one in the "Default" theme.

So you can edit the one from the "Default" directory I think and edit it as explained above.

Do that and you'll see, it will work  ;D

Bye

SliN

that did it!  thanks a ton!

iceman~

Don't know why but after doing these changes .. i started receiving a lot of errors.

Undefined offset: 214
File: /home/****/public_html/****/cache/lang_UsersOnlineToday_english_default.php (main sub template - eval?)
Line: 122

Had posted about it here .... http://www.simplemachines.org/community/index.php?topic=234316.0

As suggested i ran this query .....

REPLACE INTO smf_settings VALUES ('disableTemplateEval', 1);

and realised that the errors were generated by the BoardIndex.template.php file. I even started getting a lot of package's installation errors.

I then deleted the changes made here and voila all Undefined offset problems got sorted out.

what could the problem be ??

Guys need recent post and don't wanna get errors ... could someone help.

Thanks for bearing with me.
A wise monkey never monkies with another monkey's monkey

metallica48423

#20
<img src="', $settings['images_url'], '/post/xx.gif" alt="', $txt[214], '" border="0" /></a>

is whats causing the undefined offset errors.

First of all, it would be $txt['214'], not $txt[214] (so anyone using this code on 1.1 likely has the same issue), however, that variable does not exist in 2.0 either because language string indexes were changed to make more sense than having a number.

Change $txt[214] to $txt['recent_posts']
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

ryanhellyer

Thanks slinouille :) That works flawlessly.

It is now in action on my (under development) forum ... http://pixopoint.com/forum/index.php

ryanhellyer

Er, actually, I take that back. It isn't useful at all as it just spits out the default SSI code.

I just blindly copy and pasted and didn't realise it was just using a basic SSI function. When I went to rejig the HTML, I then realised I couldn't as it's tied into the SSI.php file :(

Any ideas on how to do this with custom code? ... without modifying SSI.php


ryanhellyer

Darn it. I've been bashing my head against my PC for the past hour trying to nut this out.

I couldn't figure out why on earth this following code wouldn't work ...

<?php
require(
'SSI.php');

$array ssi_recentPosts(5null'array');
foreach ($array as $recent) {echo '
<ul>
<li>'
$recent['subject'], '</li>
<li>'
$recent['poster']['name'], '</li>
</ul>'
;
}

?>


I eventually tested it on a 1.1.4 forum. It works on 1.1.4, but not on my 2.0 Beta 3 forum.

Anyone know how to get this working for the new beta?

metallica48423

The syntax has changed from 1.1 to 2.0 slightly.

This is it for 2.0

Quotefunction ssi_recentPosts($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo')

so it'd be


<?php
ssi_recentPosts
(5, array('board''ids''to''exclude''from''list'), array('board''ids''to''include'), 'array')
?>


Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool


Advertisement: