First Post on Every Page [Now SMF 2.0.1 compatible]

Started by live627, October 31, 2008, 10:38:36 AM

Previous topic - Next topic

shazoo!

I read through the comments but am still wondering if it's possible to select a non-sticky post to show the first post on every page?

Kermit

Quote from: shazoo! on April 05, 2012, 06:07:53 PM
I read through the comments but am still wondering if it's possible to select a non-sticky post to show the first post on every page?

There is no such option like to make just one topic to show first post on every page,if to be honest,this would require kinda much work for me and as me is not the expert in coding,i would rather leave it as it is
My Mods
Please don't PM/mail me for support,unless i invite you
Formerly known as Duncan85
Quote
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."

A. Einstein

shazoo!


hcfwesker

Quote from: shazoo! on April 05, 2012, 06:07:53 PM
I read through the comments but am still wondering if it's possible to select a non-sticky post to show the first post on every page?

I know it's late, but this may be what you're looking for.  http://custom.simplemachines.org/mods/index.php?mod=3110

allows you to set any post of any topic as the sticky post, and shows at the top of every page of that topic.

luuuciano

Thanks a lot for this mod Kermit, it is very interesting and useful...

BTW... where we can change/add a style, for that 1st post showed everywhere? can we add that?

I want to change the background, or maybe adding a new green border, or something like that... to make more obvious that is a post that came from the 1st one (a mirror of it)... outside the regular reply path
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

Kermit

Quote from: luuuciano on May 26, 2012, 02:55:09 PM
Thanks a lot for this mod Kermit, it is very interesting and useful...

BTW... where we can change/add a style, for that 1st post showed everywhere? can we add that?

I want to change the background, or maybe adding a new green border, or something like that... to make more obvious that is a post that came from the 1st one (a mirror of it)... outside the regular reply path

There is no option to change the layout of border and honestly i don't plan to add new features in near future
My Mods
Please don't PM/mail me for support,unless i invite you
Formerly known as Duncan85
Quote
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."

A. Einstein

dimiurg

Hello Kermit,

thank you again for the mod - but please let me know if you are planning to add 2.0.3 compatibility?

luuuciano

There is an annoying issue when thread has many pages and the link points to the "first real" reply on that page...

I mean, for example... page 2... the 1st post is the number one... of course, we are using this mod! :)...
The problem is that the anchor link to the 1st real reply (below the 1st post on every page...) is not located on the "second place"... so the pointer goes up, and maybe some people do not see that reply... because when there is another reply it points where its belong...
Or, maybe... the anchor link is always -1 on pages +1?
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

luuuciano

Quote from: Kermit on May 29, 2012, 12:54:15 PM
Quote from: luuuciano on May 26, 2012, 02:55:09 PM
Thanks a lot for this mod Kermit, it is very interesting and useful...

BTW... where we can change/add a style, for that 1st post showed everywhere? can we add that?

I want to change the background, or maybe adding a new green border, or something like that... to make more obvious that is a post that came from the 1st one (a mirror of it)... outside the regular reply path

There is no option to change the layout of border and honestly i don't plan to add new features in near future

Well... I have tried editing the Display.template.php file, from:

<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg' : 'windowbg2') : 'approvebg', '">

to

<div class="', $message['approved'] ? ( empty($message['counter']) ? 'windowbgfirst' : ($message['alternate'] == 0 ? 'windowbg2' : 'windowbg')) : 'approvebg', '">

And added at the theme CSS file the .windowbgfirst background style, and "Common styles used to add corners to divisions" styles section was added too...

In a regular thread it works!
But... how is it build the 1st post in every page? do not follow that file...

I was reading the mod changes, trying to figure it out... but do not get it :(

OR... maybe may idea was wrong... and I should not use empty($message['counter']) to achieve it... ?
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

Hristo

#169
Thanks to the author for this useful mod!


Quote from: luuuciano on May 26, 2012, 02:55:09 PM
Thanks a lot for this mod Kermit, it is very interesting and useful...

BTW... where we can change/add a style, for that 1st post showed everywhere? can we add that?

I want to change the background, or maybe adding a new green border, or something like that... to make more obvious that is a post that came from the 1st one (a mirror of it)... outside the regular reply path

luuuciano, here is what did the job for me:

Before installing the mod open installrc5.xml and find:
<operation>
<search position="replace"><![CDATA[ // Show the member's signature?
if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
echo '
<div class="signature" id="msg_', $message['id'], '_signature">', $message['member']['signature'], '</div>';

echo '
</div>
</div>
<span class="botslice"><span></span></span>
</div>
<hr class="post_separator" />';]]></search>
<add><![CDATA[ // Show the member's signature?
if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
echo '
<div class="signature" id="msg_', $message['id'], '_signature">', $message['member']['signature'], '</div>';

echo '
</div>
</div>
<span class="botslice"><span></span></span>
</div>
<hr class="post_separator" />';

if (!empty($modSettings['boards_FirstPostOnEveryPage']))
{
$boards_FirstPostOnEveryPage_active = explode(",", preg_replace("/[^0-9,]/", "", $modSettings['boards_FirstPostOnEveryPage']));
foreach ($boards_FirstPostOnEveryPage_active as $key => $value) if ($value == "") unset($boards_FirstPostOnEveryPage_active[$key]);
}
else $boards_FirstPostOnEveryPage_active = array();

if (!empty($modSettings['enableFirstPostOnEveryPage']) && $message['id'] == $context['topic_first_message'] && !empty($modSettings['enableFirstPostOnlySticky']) && (in_array($context['current_board'], $boards_FirstPostOnEveryPage_active) || empty($boards_FirstPostOnEveryPage_active)) && !empty($options['first_post_on_every_page']))
{
if($context['is_sticky'])
{
echo '
<div class="cat_bar">
<h3 class="catbg">&nbsp;</h3>
</div>';
}
}
elseif (!empty($modSettings['enableFirstPostOnEveryPage']) && empty($modSettings['enableFirstPostOnlySticky']) && $message['id'] == $context['topic_first_message'] && (in_array($context['current_board'], $boards_FirstPostOnEveryPage_active) || empty($boards_FirstPostOnEveryPage_active)) && !empty($options['first_post_on_every_page']))
{
echo '
<div class="cat_bar">
<h3 class="catbg">&nbsp;</h3>
</div>';
}
]]></add>
</operation>


Replace with:
<operation>
<search position="replace"><![CDATA[// Show the message anchor and a "new" anchor if this message is new.
if ($message['id'] != $context['first_message'])
echo '
<a id="msg', $message['id'], '"></a>', $message['first_new'] ? '<a id="new"></a>' : '';
]]></search>
<add><![CDATA[// Show the message anchor and a "new" anchor if this message is new.
if ($message['id'] != $context['first_message'])
echo '
<a id="msg', $message['id'], '"></a>', $message['first_new'] ? '<a id="new"></a>' : '';

if (!empty($modSettings['boards_FirstPostOnEveryPage']))
{
$boards_FirstPostOnEveryPage_active = explode(",", preg_replace("/[^0-9,]/", "", $modSettings['boards_FirstPostOnEveryPage']));
foreach ($boards_FirstPostOnEveryPage_active as $key => $value) if ($value == "") unset($boards_FirstPostOnEveryPage_active[$key]);
}
else $boards_FirstPostOnEveryPage_active = array();

if (!empty($modSettings['enableFirstPostOnEveryPage']) && $message['id'] == $context['topic_first_message'] && !empty($modSettings['enableFirstPostOnlySticky']) && (in_array($context['current_board'], $boards_FirstPostOnEveryPage_active) || empty($boards_FirstPostOnEveryPage_active)) && !empty($options['first_post_on_every_page']))
{
if($context['is_sticky'])
{
echo '
<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg fpoep_sticky' : 'windowbg2') : 'approvebg', '">
<span class="topslice"><span></span></span>
<div class="post_wrapper">';
}
}
elseif (!empty($modSettings['enableFirstPostOnEveryPage']) && empty($modSettings['enableFirstPostOnlySticky']) && $message['id'] == $context['topic_first_message'] && (in_array($context['current_board'], $boards_FirstPostOnEveryPage_active) || empty($boards_FirstPostOnEveryPage_active)) && !empty($options['first_post_on_every_page']))
{
echo '
<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg fpoep' : 'windowbg2') : 'approvebg', '">
<span class="topslice"><span></span></span>
<div class="post_wrapper">';
}
else]]></add>
</operation>



Then install the mod. As you can see this adds a new class .fpoep / .fpoep_sticky to the .windowbg class of the first post. Style it as you want.

Edit: Forgot that I'm using custom theme! Changed the place of the new classes to .windowbg, that will be better place for the Curve theme.

luuuciano

Hristo, but what happened with the member signature?
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

Hristo

I do not allow signatures, but these changes should not influence the signature. If you have not noticed this is entirely different <operation> ... </operation> and does not include the signature.

Edit: Enabled the signatures, just to test it and everything looks normal.

luuuciano

Oh, now I see... I have tried it (but using the codes needed on my theme)...
Now... it ads that class below the first message content... like a separator between the 1st and 2nd post
Is that the idea?

Because I was thinking on changing the first message background... so I need to change the 1st message class, mmmmmm

(anyway, having a separator looks nice, lol... but I want something more obvious, like a different background colour)
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

Hristo

Quote from: luuuciano on July 08, 2013, 09:19:24 PM
Now... it ads that class below the first message content... like a separator between the 1st and 2nd post
Is that the idea?
This is done by the original mod

Quote from: luuuciano on July 08, 2013, 09:19:24 PM
Because I was thinking on changing the first message background... so I need to change the 1st message class, mmmmmm

And exactly this is achieved by the changes above - adds a new class to .windowbg on the first post (only on the first post). That allows to target only the first post.

Check the attached example screenshot

P. S. I do not understand PHP, but the above change was simple enough to figure it out and thus far works without errors.

luuuciano

But... you have changed a section used to add a separator... and why that changes will change the code below it?

My example is http://cba.b.ikers.com.ar/index.php/topic,9740.msg135774.html#msg135774
look that tinny green line below the first post...
I have used:

echo '
<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbgfirst' : 'windowbg2') : 'approvebg', '">
<h3 class="catbg">&nbsp;</h3>
</div>';


Look at the page code where is added the windowbgfirst


Using
echo '
<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg windowbgfirst' : 'windowbg2') : 'approvebg', '">
<span class="topslice"><span></span></span>
<div class="post_wrapper">';

did a more odd behavior
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

Hristo

No, no, it's not that simple. You have to make all the changes, not only small part of them.

Lets try this (will work if the code on your site is not changed after the mod install)

Find and delete this code:



if (!empty($modSettings['boards_FirstPostOnEveryPage']))
{
$boards_FirstPostOnEveryPage_active = explode(",", preg_replace("/[^0-9,]/", "", $modSettings['boards_FirstPostOnEveryPage']));
foreach ($boards_FirstPostOnEveryPage_active as $key => $value) if ($value == "") unset($boards_FirstPostOnEveryPage_active[$key]);
}
else $boards_FirstPostOnEveryPage_active = array();

if (!empty($modSettings['enableFirstPostOnEveryPage']) && $message['id'] == $context['topic_first_message'] && !empty($modSettings['enableFirstPostOnlySticky']) && (in_array($context['current_board'], $boards_FirstPostOnEveryPage_active) || empty($boards_FirstPostOnEveryPage_active)) && !empty($options['first_post_on_every_page']))
{
if($context['is_sticky'])
{
echo '
<div class="cat_bar">
<h3 class="catbg">&nbsp;</h3>
</div>';
}
}
elseif (!empty($modSettings['enableFirstPostOnEveryPage']) && empty($modSettings['enableFirstPostOnlySticky']) && $message['id'] == $context['topic_first_message'] && (in_array($context['current_board'], $boards_FirstPostOnEveryPage_active) || empty($boards_FirstPostOnEveryPage_active)) && !empty($options['first_post_on_every_page']))
{
echo '
<div class="cat_bar">
<h3 class="catbg">&nbsp;</h3>
</div>';
}


Then find:

// Show the message anchor and a "new" anchor if this message is new.
if ($message['id'] != $context['first_message'])
echo '
<a id="msg', $message['id'], '"></a>', $message['first_new'] ? '<a id="new"></a>' : '';


Replace it with:

/ Show the message anchor and a "new" anchor if this message is new.
if ($message['id'] != $context['first_message'])
echo '
<a id="msg', $message['id'], '"></a>', $message['first_new'] ? '<a id="new"></a>' : '';

if (!empty($modSettings['boards_FirstPostOnEveryPage']))
{
$boards_FirstPostOnEveryPage_active = explode(",", preg_replace("/[^0-9,]/", "", $modSettings['boards_FirstPostOnEveryPage']));
foreach ($boards_FirstPostOnEveryPage_active as $key => $value) if ($value == "") unset($boards_FirstPostOnEveryPage_active[$key]);
}
else $boards_FirstPostOnEveryPage_active = array();

if (!empty($modSettings['enableFirstPostOnEveryPage']) && $message['id'] == $context['topic_first_message'] && !empty($modSettings['enableFirstPostOnlySticky']) && (in_array($context['current_board'], $boards_FirstPostOnEveryPage_active) || empty($boards_FirstPostOnEveryPage_active)) && !empty($options['first_post_on_every_page']))
{
if($context['is_sticky'])
{
echo '
<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg fpoep_sticky' : 'windowbg2') : 'approvebg', '">
<span class="topslice"><span></span></span>
<div class="post_wrapper">';
}
}
elseif (!empty($modSettings['enableFirstPostOnEveryPage']) && empty($modSettings['enableFirstPostOnlySticky']) && $message['id'] == $context['topic_first_message'] && (in_array($context['current_board'], $boards_FirstPostOnEveryPage_active) || empty($boards_FirstPostOnEveryPage_active)) && !empty($options['first_post_on_every_page']))
{
echo '
<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg fpoep' : 'windowbg2') : 'approvebg', '">
<span class="topslice"><span></span></span>
<div class="post_wrapper">';
}
else


Then add this to your theme's index.css (just an example)

.fpoep .topslice, .fpoep .topslice span, .fpoep .botslice, .fpoep .botslice span {
background: none !important;
}
.fpoep {
background: rgb(235, 180, 180);
border-radius: 12px;
border: 1px solid red;
margin: -1px;
}

luuuciano

Ohhhh, I understand now!
Now I realize why "Show the message anchor and a "new" anchor if this message is new." was there, I thought you wrote it... lol (it must be too late...)
Tomorrow will find those sections and do the proper changes, thanks a lot for the patience!
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).


charuzzi

Is there any way to enable FPOEP on SMF 2.0.6?

I use Ostara theme now.

Please advise.

Thanks in advance guys

Hristo

I said myself to not answer such questions anymore, because the team is stubborn enough to acknowledge that the next link should be on each mod's page. But as I see Apostaganha's questions has not been answered too, so here it is:
http://wiki.simplemachines.org/smf/How_can_I_install_a_mod_that_doesn%27t_work_in_my_SMF_version

just change it to 2.0.2 (for example) and it will install on 2.0.6

Advertisement: