News:

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

Main Menu

Last post on each page

Started by TourFL, March 14, 2016, 09:26:19 AM

Previous topic - Next topic

TourFL

I'm raising that post again, as this has been forgotten far away in the history of the forum  ;D

I see this still doesn't exists for SMF (saw it on other kinds of forums). So if somebody knows how to do it, or maybe, how to modify the mod displaying the first message at the top of each page, in order to display the previous message instead, that would be great!

Thanks
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

Steve

I would love this as well. I hate clicking on the new icon only to find out I'm on a new page so now I have to go back to the previous page to read what was being talked about.
DO NOT pm me for support!

Pipke

This will do something as it looks to me it works fine, it could be i'm missing some checks?

last message of the previous page, here goes on smf 2.0.11

Display.php

Code (find) Select

$context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true);


Code (replace by) Select

$context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page']-1, true);


MessageIndex.php

Code (find) Select

$maxindex = isset($_REQUEST['all']) && !empty($modSettings['enableAllMessages']) ? $board_info['total_topics'] : $context['topics_per_page'];


Code (add after) Select

$context['messages_per_page'] = $context['messages_per_page']-1;


"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

dougiefresh

#3
Nope, that's not going to work.  In Display.php, all you're doing is changing how the page index is built, which has nothing to do with the data being displayed.  In MessageIndex.php (applies to Display.php as well), it's even worse because you're showing the user more pages than what exists.....

In Sources/Display.php, search for this:
Code (Find) Select
if ($start >= $context['total_visible_posts'] / 2 && $context['messages_per_page'] != -1)and add this BEFORE that statement:
Code (Add Before) Select
if ($start > 0)
{
$start--;
$limit++;
}
Then look for this:
Code (Find) Select
$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];and REPLACE with this:
Code (Replace) Select
$counter = max(0, (empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']) - 1);
This should provide you with the functionality you are looking for.....  I'll post a mod in a few minutes....

EDIT: Mod is available here!!!

TourFL

It works great! Thanks a lot!

Now, if you need ideas for the version 2.0, you can change the style of the repeated post or add some text showing this is a recall (is this the word in english?) of the previous post   ;D

Thanks a lot for this new mod!

If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

Steve

Brilliant! Thanks Dougie!

Quote from: TourFL on March 29, 2016, 05:25:47 AM... this is a recall (is this the word in english?) of the previous post ...

It's as good a word as any. I might have said 'copy' but yours works too. ;D
DO NOT pm me for support!

TourFL

#6
I found how to improve a bit this mod, but as I'm not familiar with PHP and SMF programming, it is a bit "brutal", and I may have missed something  :-\

in Display.php:
before

        // Do the censor thang.
censorText($message['body']);
censorText($message['subject']);


insert:

        if ($counter == ($context['start'] - 1))
        $message['body'] = "[b]Copy of previous message:[/b]\n\n".$message['body'];

The test checks that our reply number is the requested first post of the page -1 (so this is the repeated message).
From there I hardcoded the text to add before the actual message. It would obviously be cleaner to have the standard SMF way to display text (with variable set in language files), but I didn't have time yet to see how it works.

For me, it works already fine like this!

If somebody would know how to do it, there are 2 other things I would like to add  ;D
One reproach the members of my forum did to this functionality, is repeating a message full of images.
it would be great to add some parsing to remove the pictures of the copied message and possibly replace with some message "[image was here]" or something like this.

Another interesting addition would be to remove the functionalities of the repeated message: "quote", "remove", "modify", "separate", etc
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

dougiefresh

I had submitted the mod to the Customization Site and the mod was rejected because it was too small.  The Customization Team felt it would be better as a tip/trick thing, but it would be nice to see it as an approved mod, so I guess it needs to be expanded upon....  O:)

Thanks for the ideas!  I'll see what I can do, however, removing functionality probably isn't a good idea, and I think it should be optional and up to the admin to set that to their preference....  Likewise with the pictures....

Biology Forums

I've read the description several times, but I'm not understanding why this is required. Could someone post an imagine of this in action?

Steve

Read my first post in this thread. It pretty well explains why this has been asked for. It's not required, it's a nice thing to have imo. :)
DO NOT pm me for support!

TourFL

Exemple: On your forum, you have a topic of  several pages with new unread message. You click on the "New" icon to go directly to the last unread message. New page appears with only one message saying "Yes, you're totally right, we should do that" ... if you don't remember what was on the previous message, you don't know what he's talking about.
You then have to go to previous page and scroll to bottom to read it. The idea of that mod is to repeat the previous post at the top of each page (except the first one).
I got only good feedback from that modification on my forum since I installed it  ;)
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

dougiefresh

Quote from: TourFL on March 30, 2016, 09:31:06 AM
I found how to improve a bit this mod, but as I'm not familiar with PHP and SMF programming, it is a bit "brutal", and I may have missed something  :-\

in Display.php:
before

        // Do the censor thang.
censorText($message['body']);
censorText($message['subject']);


insert:

        if ($counter == ($context['start'] - 1))
        $message['body'] = "[b]Copy of previous message:[/b]\n\n".$message['body'];

The test checks that our reply number is the requested first post of the page -1 (so this is the repeated message).
From there I hardcoded the text to add before the actual message. It would obviously be cleaner to have the standard SMF way to display text (with variable set in language files), but I didn't have time yet to see how it works.
This idea has been implemented properly by replacing "Reply #[n] on:" with "Reply #[n] from previous page:" in the header....

Quote from: TourFL on March 30, 2016, 09:31:06 AM
For me, it works already fine like this!
Good to hear!

Quote from: TourFL on March 30, 2016, 09:31:06 AM
If somebody would know how to do it, there are 2 other things I would like to add  ;D
One reproach the members of my forum did to this functionality, is repeating a message full of images.
it would be great to add some parsing to remove the pictures of the copied message and possibly replace with some message "[image was here]" or something like this.

Another interesting addition would be to remove the functionalities of the repeated message: "quote", "remove", "modify", "separate", etc
I can do them....

dougiefresh

#12
Okay, version 1.1 is up on my website here.  Tell me what y'all think of it....

Btw, I've also fixed the mod name and description.  It now reads "Last post from previous page" instead of "Last page on each page"....  :P

Quote from: Shuban on March 30, 2016, 01:04:22 PMI've read the description several times, but I'm not understanding why this is required. Could someone post an imagine of this in action?
I assume you're talking about the mod description, right?  If so, can you read the first post on this thread, then tell me how you would phrase the mod description.  Feedback would be appreciated!

TourFL

Thanks a lot again!

I just had problem with the last modification (n°4) from Display.php. Installer says it fine, but I ended with the '}' at the beginning of my file (maybe just a problem with my forum). But once I found where to put it, it was working great!
And it's very cool to have everything as options in the management page!

On my side, I still kept the modification of the repeated message text, it makes it clearer than the indication next to the message number, in my opinion  :)

If you want the French translation:
ManageSettings.french-utf8.php

$txt['LPOEP_show_last_post'] = ' Répéter le dernier message de la page précédente en début de page?';
$txt['LPOEP_dim_css'] = 'Att&eacute;nuer le message r&eacute;p&eacute;t&eacute; de:<div class="smalltext"><strong>0</strong> pour d&eacute;sactiver.</div>';
$txt['LPOEP_undim_hover'] = 'D&eacute;satt&eacute;nuer en placant le curseur sur le message  r&eacute;p&eacute;t&eacute;?';
$txt['LPOEP_remove_images'] = 'Cacher les images du message  r&eacute;p&eacute;t&eacute;?';
$txt['LPOEP_remove_function'] = 'Enlever les boutons de controle du message r&eacute;p&eacute;t&eacute;?<div class="smalltext">Citations, modification, suppression, etc</div>';


index.french-utf8.php

$txt['post_from_previous_page'] = ' de la page pr&eacute;c&eacute;dente';



Thanks again for that great work!

Quote from: dougiefresh on March 30, 2016, 06:37:02 PM
I assume you're talking about the mod description, right?  If so, can you read the first post on this thread, then tell me how you would phrase the mod description.  Feedback would be appreciated!
In fact, the first post was for some reason separated from the rest... Original message is here: http://www.simplemachines.org/community/index.php?topic=493110.msg3456357#msg3456357
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

dougiefresh

Quote from: TourFL on March 31, 2016, 04:23:02 AM
I just had problem with the last modification (n°4) from Display.php. Installer says it fine, but I ended with the '}' at the beginning of my file (maybe just a problem with my forum). But once I found where to put it, it was working great!
And it's very cool to have everything as options in the management page!
It's been fixed and reuploaded!!  Thanks!

Quote from: TourFL on March 31, 2016, 04:23:02 AM
If you want the French translation:
ManageSettings.french-utf8.php

$txt['LPOEP_show_last_post'] = ' R&eacute;p&eacute;ter le dernier message de la page pr&eacute;c&eacute;dente en d&eacute;but de page?';
$txt['LPOEP_dim_css'] = 'Att&eacute;nuer le message r&eacute;p&eacute;t&eacute; de:<div class="smalltext"><strong>0</strong> pour d&eacute;sactiver.</div>';
$txt['LPOEP_undim_hover'] = 'D&eacute;satt&eacute;nuer en placant le curseur sur le message  r&eacute;p&eacute;t&eacute;?';
$txt['LPOEP_remove_images'] = 'Cacher les images du message  r&eacute;p&eacute;t&eacute;?';
$txt['LPOEP_remove_function'] = 'Enlever les boutons de controle du message r&eacute;p&eacute;t&eacute;?<div class="smalltext">Citations, modification, suppression, etc</div>';


index.french-utf8.php

$txt['post_from_previous_page'] = ' de la page pr&eacute;c&eacute;dente';

The translation has been included in the new version 1.1.  Thank you very much!

Quote from: TourFL on March 31, 2016, 04:23:02 AM
Quote from: dougiefresh on March 30, 2016, 06:37:02 PM
I assume you're talking about the mod description, right?  If so, can you read the first post on this thread, then tell me how you would phrase the mod description.  Feedback would be appreciated!
In fact, the first post was for some reason separated from the rest... Original message is here: http://www.simplemachines.org/community/index.php?topic=493110.msg3456357#msg3456357
We need to inform somebody about this, because this situation isn't right....

TourFL

Maybe it was split because the original post was from 2012.
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

dougiefresh

But without the first post from the other thread, this thread makes no sense.....

Steve

Works great dougie but I have a suggestion if it's not too complicated.

In the duplicated post where it says [Image] can that be an actual link to the image in the previous post?
DO NOT pm me for support!

Irisado

Quote from: TourFL on March 31, 2016, 04:59:08 AM
Maybe it was split because the original post was from 2012.

That is why it was split, yes.

Posting a link to the old topic, as has been done, solves the issue of relating the two, as would quoting any relevant information from the old topic and posting it in replies here.  Replies raising topics from the dead are normally split to form new topics.
Soñando con una playa donde brilla el sol, un arco iris ilumina el cielo, y el mar espejea iridescentemente

Biology Forums

Quote from: TourFL on March 30, 2016, 01:52:33 PM
Exemple: On your forum, you have a topic of  several pages with new unread message. You click on the "New" icon to go directly to the last unread message. New page appears with only one message saying "Yes, you're totally right, we should do that" ... if you don't remember what was on the previous message, you don't know what he's talking about.
You then have to go to previous page and scroll to bottom to read it. The idea of that mod is to repeat the previous post at the top of each page (except the first one).
I got only good feedback from that modification on my forum since I installed it  ;)

Makes total sense now... Interesting idea

Advertisement: