News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Sticky any post

Started by emanuele, August 23, 2011, 09:39:17 PM

Previous topic - Next topic

emanuele

Link to Mod

When installed a new option is provided that allows setting any post of any topic (also non-sticky) as "sticky".

Once set sticky the message will be shown as the first of the topic and it will be repeated on all the pages of the topic.

A user must have the Make topics sticky permission in order to be able to use this function.

The option can be turned on and off through the admin panel in Forum > Posts and Topics > Topic Settings

Available also at https://github.com/emanuele45/Sticky-any-post

To do list:

  • Better separate the sticked post from the others
  • Allow sticky multiple posts

Change log

  • 0.1.5 Fixed bug reported by Geor'G: topics with sticky posts disappear when the mod is disabled
  • 0.1.4
    • fixed a bug: wrong post numbering in display
    • fixed the bug reported by Apostaganha
    • added license
  • 0.1.3 fixed bug reported by Apostaganha
  • 0.1.2 initial release


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

_Newbie_

Nice job...

I'll use this for sure, thanks!

Hank Scott

I installed this mod as directed (under SMF 2.0 running the default theme Curve), but when attempting to modify a post (to set it as sticky) I get the following error:

Database Error: Operand should contain 1 column(s)
File: /home/.../public_html/forum/Sources/Post.php
Line: 149

I have no idea what is causing this, but I checked all the files to be sure all changes were made correctly.

This problem stopped once I reinstalled the original files.

Also, there were no instructions on where to install or how to run or use installScript_SMF2.php and installHooks.php files, so I put them in the folder where the forum in installed and tried to run them from my browser, which resulted in a black page for each attempt.

Please advise how to install properly.

Thanks,

Hank

emanuele

Quote from: Hank Scott on September 03, 2011, 06:43:36 PM
I installed this mod as directed (under SMF 2.0 running the default theme Curve), but when attempting to modify a post (to set it as sticky) I get the following error:

Database Error: Operand should contain 1 column(s)
File: /home/.../public_html/forum/Sources/Post.php
Line: 149

I have no idea what is causing this, but I checked all the files to be sure all changes were made correctly.

This problem stopped once I reinstalled the original files.
So now you have the mod installed or not?
Not exactly sure what can cause this error... :-[

Quote from: Hank Scott on September 03, 2011, 06:43:36 PM
Also, there were no instructions on where to install or how to run or use installScript_SMF2.php and installHooks.php files, so I put them in the folder where the forum in installed and tried to run them from my browser, which resulted in a black page for each attempt.

Please advise how to install properly.
Thanks for the suggestion, I'll put something. ;)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

andershz

When a post is made sticky it will show both first on every page and in the place where it would normally show. 
This has the side effect that if the first post of any page is made sticky it will appear duplicated.
Maybe it would be better to suppress the additional appearance if the post is first on the page anyway.

emanuele

Yep, this is a weak point... I would first give a different aspect and better separate the sticked post from all the others.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

vkbr

changing background color perhaps...

emanuele

Yep, definitely is one of the things to do. :)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.


emanuele

Thank you for the report and sorry for the late reply!

Fixed

But more I look at this mod less I like it. I've to rewrite it...it will take a while...a long while (computer problems ::)).


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Apostaganha

Quote from: emanuele on October 27, 2011, 09:03:14 AM
Thank you for the report and sorry for the late reply!

Fixed

But more I look at this mod less I like it. I've to rewrite it...it will take a while...a long while (computer problems ::)).

Ant it messes with the links for the last post of each topic :s

emanuele

#11
How?


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

chinaren

This seems to work fine for me as an Admin, but doesn't show up for other users. 


Am I doing anything wrong? 
The Opus Path - The Next Generation of the Written Word

emanuele

#13
Do you mean the possibility to "stick" a post?
It relies on the "make_sticky" permission (Make topics sticky), so AFAIR normally only moderators should have it.

Quote from: Apostaganha on October 27, 2011, 09:48:45 AM
Quote from: emanuele on October 27, 2011, 09:03:14 AM
Thank you for the report and sorry for the late reply!

Fixed

But more I look at this mod less I like it. I've to rewrite it...it will take a while...a long while (computer problems ::)).

Ant it messes with the links for the last post of each topic :s
Finally I got it, sorry.
Not it should be fixed.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

chinaren

Quote from: emanuele on October 30, 2011, 10:19:29 AM
Do you mean the possibility to "stick" a post?
It relies on the "make_sticky" permission (Make topics sticky), so AFAIR normally only moderators should have it.


Oh, that's a bummer.  Any chance of adding a permission that allows other groups to do this?


Also I have the bug that if you sticky the first post it repeats the first post on the second post, essentially overwriting the second post, though if you un-sticky the first post the second post reverts back to what it was.

The Opus Path - The Next Generation of the Written Word

emanuele

Quote from: chinaren on October 30, 2011, 06:35:13 PM
Oh, that's a bummer.  Any chance of adding a permission that allows other groups to do this?
I'm not particularly keen on adding another permission just for this.

It can be added quite easily (I forgot to remove the hook that I added a while ago, so it's even easier). Oh well... look at this one.

If you want you can:
1) add the following code to Subs-StickyMessage.php
function stickymessage_add_permissions(&$permissionGroups, &$permissionList, &$leftPermissionGroups, &$hiddenPermissions, &$relabelPermissions){
global $context;

$context['non_guest_permissions'][] = 'make_post_sticky';
$permissionList['board']['make_post_sticky'] = array(false, 'topic', 'moderate');
}


2) in modification_SMF2.xml replace almost all the:
allowedTo('make_sticky')
with
allowedTo('make_post_sticky')

the only exception is:
<operation><!-- 7 -->
<search position="after"><![CDATA[
if (isset($_POST['sticky']) && (empty($modSettings['enableStickyTopics']) || empty($_POST['sticky']) || !allowedTo('make_sticky')))]]></search>
<add><![CDATA[
if (isset($_POST['sticky_message']) && (empty($modSettings['enable_sticky_message']) || empty($_POST['sticky_message']) || !allowedTo('make_sticky')))
unset($_POST['sticky_message']);
]]></add>
</operation>


that must become:
<operation><!-- 7 -->
<search position="after"><![CDATA[
if (isset($_POST['sticky']) && (empty($modSettings['enableStickyTopics']) || empty($_POST['sticky']) || !allowedTo('make_sticky')))]]></search>
<add><![CDATA[
if (isset($_POST['sticky_message']) && (empty($modSettings['enable_sticky_message']) || empty($_POST['sticky_message']) || !allowedTo('make_post_sticky')))
unset($_POST['sticky_message']);
]]></add>
</operation>


3) to lang.xml and lang-UTF8.xml add:
$txt['permissionname_make_post_sticky'] = 'Make posts sticky';


Quote from: chinaren on October 30, 2011, 06:35:13 PM
Also I have the bug that if you sticky the first post it repeats the first post on the second post, essentially overwriting the second post, though if you un-sticky the first post the second post reverts back to what it was.
This is fixed (see here), just uninstall the version you are using, download the last one and re-install it. ;)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

chinaren

Thanks for all that Em!


My forum is being worked on atm, but I'll do all the above as soon as the other stuff is done. :)
The Opus Path - The Next Generation of the Written Word

emanuele

Quote from: emanuele on November 01, 2011, 09:22:03 AM
It can be added quite easily (I forgot to remove the hook that I added a while ago, so it's even easier). Oh well... look at this one.
Quoting because it was partially hidden in the middle of a lot of changes, so I don't know if you have seen it or not. ;)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Geor'G

#18
1. If disabled:


Then the message disappears:


2. Variable is not used. Probably forgot about it.
$txt['sticky_message_disabled'] = 'Sorry, the sticky topic function is disabled';

---------------------------------
Sorry for my english

emanuele

I have a pretty messy test forum at the moment, but I can't replicate the issue...I'll try again with a clean install tomorrow.
Are you using the latest version of the mod?


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Advertisement: