[DEV] Sticky Post within Topic

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
LifeIsPain
Former Team Member
Posts: 2148
Joined: Tue Oct 01, 2002 7:04 am
Location: Way Way Behind

Post by LifeIsPain »

That is for the user to specify if they should always see the first post, my mod allows the moderator to specify which threads show the post. The are both different (and I don't see that mod as an attempt to get into the database here) and I personally prefer the way mine works.
LifeIsPain - one who needs to be smackedLife is pain, highness! Anyone who says differently is selling something.
User avatar
hunger_for_sites
Registered User
Posts: 58
Joined: Fri Mar 28, 2003 11:23 am
Location: behind you
Contact:

Post by hunger_for_sites »

can it be possible if the sticky post has a different color?
i did have a signature...
LifeIsPain
Former Team Member
Posts: 2148
Joined: Tue Oct 01, 2002 7:04 am
Location: Way Way Behind

Post by LifeIsPain »

Yes, in templates/subSilver/viewtopic_body.tpl do the following:

Code: Select all

#--------[ FIND ]--------
<td class="row2" colspan="2"><div class="gen">

#--------[ REPLACE WITH ]--------
<td class="row2" style="background-color: #FFFFFF;" colspan="2"><div class="gen">
Or replace #FFFFFF with whatever color you want to use.
LifeIsPain - one who needs to be smackedLife is pain, highness! Anyone who says differently is selling something.
User avatar
hunger_for_sites
Registered User
Posts: 58
Joined: Fri Mar 28, 2003 11:23 am
Location: behind you
Contact:

Post by hunger_for_sites »

can it be like this when posting a sticky post?

Image


notice that the "make post sticky" is checked meaning that the post will be a sticky post.

(the pic you see above is only an example and it doesn't exist yet until it is developed.)
Last edited by hunger_for_sites on Sat May 31, 2003 10:43 am, edited 2 times in total.
i did have a signature...
LifeIsPain
Former Team Member
Posts: 2148
Joined: Tue Oct 01, 2002 7:04 am
Location: Way Way Behind

Post by LifeIsPain »

hunger_for_sites wrote: can it be like this when posting a sticky post?

Well, possibly it could be, but I don't know, because I can't see the screenshot you have given. Free hosts do this type of thing, they don't normally like hotlinking....

That said, the mod does give a make post sticky option, for the first post only, but I think you would have already figured that out, as that is the eniter point of the mod :)
LifeIsPain - one who needs to be smackedLife is pain, highness! Anyone who says differently is selling something.
User avatar
hunger_for_sites
Registered User
Posts: 58
Joined: Fri Mar 28, 2003 11:23 am
Location: behind you
Contact:

Post by hunger_for_sites »

ok, i just uploaded it in another server. can you see the pic now???
i did have a signature...
LifeIsPain
Former Team Member
Posts: 2148
Joined: Tue Oct 01, 2002 7:04 am
Location: Way Way Behind

Post by LifeIsPain »

Yes, I can see it now, and to make this change (for the first part only) you need to just change the following line in language/lang_english/lang_main.php

Code: Select all

$lang['Post_Sticky_Post'] = 'Display post at start of every page in topic';
to

Code: Select all

$lang['Post_Sticky_Post'] = 'Make post sticky';
Now if you are saying you want to be able to do that with any post in the thread, that is not possible right now, that is along the lines of what Ptirhiik - RPGnet-fr was saying in his first post (the method I don't use)
LifeIsPain - one who needs to be smackedLife is pain, highness! Anyone who says differently is selling something.
User avatar
hunger_for_sites
Registered User
Posts: 58
Joined: Fri Mar 28, 2003 11:23 am
Location: behind you
Contact:

Post by hunger_for_sites »

no response here anymore! what happend? is it over? (meaning: maybe the dev't of the mod is not finished or it's complete but it's not shown on the mod release)
i did have a signature...
LifeIsPain
Former Team Member
Posts: 2148
Joined: Tue Oct 01, 2002 7:04 am
Location: Way Way Behind

Post by LifeIsPain »

I have a few more ideas for this, but at the moment, I am working on some other mods that I believe are a bit more pressing (I am working with EasyMOD a bit, as well as work on New Fields for profiles) but for now, the development is halted.

Also, I answered your previous question, but I asked for clarification if I were wrong.
LifeIsPain - one who needs to be smackedLife is pain, highness! Anyone who says differently is selling something.
J.J.M
Registered User
Posts: 1
Joined: Fri Sep 30, 2005 2:28 am
Location: La Plata
Contact:

Post by J.J.M »

Well, hi.

I was interested in this MOD, so I install it under an un-modded 2.0.17 phpBB forum. It didn't work at the first time, but I made it some changes and it finally work!

This is the MOD with my changes in it:

Code: Select all

#
#-----[ SQL ]---------------------------------
#
ALTER TABLE `phpbb_topics` ADD `topic_stickypost` TINYINT( 1 ) DEFAULT '0' NOT NULL ;

#
#-----[ OPEN ]---------------------------------
#
posting.php

#
#-----[ FIND ]---------------------------------
#
#   NOTE: the full line to look for is:
#		$sql = "SELECT f.*, t.topic_id, t.topic_status, t.topic_type, t.topic_first_post_id, t.topic_last_post_id, t.topic_vote, p.post_id, p.poster_id" . $select_sql . " 
$sql = "SELECT f.*, t.topic_id

#
#-----[ IN-LINE FIND ]---------------------------------
#
p.poster_id

#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
, t.topic_stickypost

#
#-----[ FIND ]---------------------------------
#
		$post_data['poster_id'] = $post_info['poster_id'];

#
#-----[ AFTER, ADD ]---------------------------------
#
		$post_data['topic_stickypost'] = $post_info['topic_stickypost'];

#
#-----[ FIND ]---------------------------------
#
	}

	redirect(append_sid("login.$phpEx?redirect=posting.$phpEx&" . $redirect, true));
}

#
#-----[ AFTER, ADD ]---------------------------------
#
if( $is_auth['auth_sticky'] )
{
	$stickypost = ( !empty($HTTP_POST_VARS['stickypost']) ) ? 1 : 0;
}

#
#-----[ FIND ]---------------------------------
#
#   NOTE: the full line to look for is:
#				submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, $bbcode_uid, str_replace("\'", "''", $username), str_replace("\'", "''", $subject), str_replace("\'", "''", $message), str_replace("\'", "''", $poll_title), $poll_options, $poll_length);
submit_post($mode,

#
#-----[ IN-LINE FIND ]---------------------------------
#
);

#
#-----[ IN-LINE BEFORE, ADD ]---------------------------------
#
, $stickypost

#
#-----[ FIND ]---------------------------------
#
		$topic_type_toggle .= ' /> ' . $lang['Post_Sticky'] . '&nbsp;&nbsp;';

#
#-----[ AFTER, ADD ]---------------------------------
#
		$template->assign_block_vars('switch_stickypost_checkbox', array());
		$topic_stickypost_checked = ( $refresh || isset($HTTP_POST_VARS['del_poll_option']) ) ? $stickypost : ( ( $post_info['topic_stickypost'] ) ? 1 : 0 );

#
#-----[ FIND ]---------------------------------
#
	'L_STYLES_TIP' => $lang['Styles_tip'], 

#
#-----[ AFTER, ADD ]---------------------------------
#
	'L_STICKY_POST' => $lang['Post_Sticky_Post'],
	'S_STICKYPOST_CHECKED' => ( $topic_stickypost_checked ) ? 'checked="checked"' : '',

#
#-----[ OPEN ]---------------------------------
#
includes/functions_post.php

#
#-----[ FIND ]---------------------------------
#
#   NOTE: the full line to look for is:
# function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length)
function submit_post(

#
#-----[ IN-LINE FIND ]---------------------------------
#
)

#
#-----[ IN-LINE BEFORE, ADD ]---------------------------------
#
, &$stickypost

#
#-----[ FIND ]---------------------------------
#
		$topic_vote = (!empty($poll_title) && count($poll_options) >= 2) ? 1 : 0;

#
#-----[ AFTER, ADD ]---------------------------------
#
		$topic_stickypost = ( isset($stickypost) ) ? $stickypost : ( $post_data['topic_stickypost'] ? 1 : 0);

#
#-----[ FIND ]---------------------------------
#
#   NOTE: the full line to look for is:
#		$sql  = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type, topic_vote = $topic_vote WHERE topic_id = $topic_id";
$sql  = ($mode != "editpost") ? "INSERT INTO "

#
#-----[ IN-LINE FIND ]---------------------------------
#
topic_vote

#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
, topic_stickypost

#
#-----[ IN-LINE FIND ]---------------------------------
#
$topic_vote

#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
, $topic_stickypost

#
#-----[ IN-LINE FIND ]---------------------------------
#
(($post_data['edit_vote'] || !empty($poll_title)) ? ", topic_vote = " . $topic_vote : "")

#
#-----[ IN-LINE AFTER, ADD ]--------------------------------
#
 . ", topic_stickypost = " . $topic_stickypost 


#
#-----[ OPEN ]---------------------------------
#
templates/subSilver/posting_body.tpl

#
#-----[ FIND ]---------------------------------
#
		  <!-- END switch_delete_checkbox -->

#
#-----[ AFTER, ADD  ]---------------------------------
#
		  <!-- BEGIN switch_stickypost_checkbox -->
		  <tr> 
			<td> 
			  <input type="checkbox" name="stickypost" {S_STICKYPOST_CHECKED} />
			</td>
			<td><span class="gen">{L_STICKY_POST}</span></td>
		  </tr>
		  <!-- END switch_stickypost_checkbox -->


#
#-----[ OPEN ]---------------------------------
#
language/lang_english/lang_main.php

#
#-----[ FIND ]---------------------------------
#
$lang['Post_Normal'] = 'Normal';

#
#-----[ AFTER, ADD ]---------------------------------
#
$lang['Post_Sticky_Post'] = 'Display post at start of every page in topic';


#
#-----[ OPEN ]---------------------------------
#
viewtopic.php

#
#-----[ FIND ]---------------------------------
#
#   NOTE: the full line to look for is:
# $sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, t.topic_stickypost, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . "
$sql = "SELECT t.topic_id, t.topic_title

#
#-----[ IN-LINE FIND ]---------------------------------
#
 t.topic_last_post_id

#
#-----[ IN-LINE BEFORE, ADD ]---------------------------------
#
, t.topic_stickypost, t.topic_first_post_id

#
#-----[ FIND ]---------------------------------
#
//
// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...
//

#
#-----[ BEFORE, ADD ]---------------------------------
#
//
// Does this topic need a header post?
//
if ( !empty($forum_topic_data['topic_stickypost']) && floor( $start / intval($board_config['posts_per_page']) ) > 0)
{
	$sql = "SELECT u.username, u.user_id, p.*,  pt.post_text, pt.bbcode_uid
		FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
		WHERE p.post_id = " . $forum_topic_data['topic_first_post_id'] . "
			AND pt.post_id = p.post_id
			AND u.user_id = p.poster_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql);
	}

	if ($row = $db->sql_fetchrow($result))
	{
		$db->sql_freeresult($result);

		$poster_id = $row['user_id'];
		$poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $row['username'];

		$post_date = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);

		//
		// Handle anon users posting with usernames
		//
		if ( $poster_id == ANONYMOUS && $row['post_username'] != '' )
		{
			$poster = $row['post_username'];
			$poster_rank = $lang['Guest'];
		}

		$temp_url = '';

		if ( $poster_id != ANONYMOUS )
		{
			$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$poster_id");
			$poster_profile = '<a href="' . $temp_url . '">' . $poster . '</a>';
		}
		else
		{
			$poster_profile = $poster;
		}

		$message = $row['post_text'];
		$bbcode_uid = $row['bbcode_uid'];

		//
		// If the board has HTML off but the post has HTML
		// on then we process it, else leave it alone
		//
		if ( !$board_config['allow_html'] && $row['enable_html'] )
		{
			$message = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $message);
		}

		//
		// Parse message for BBCode if reqd
		//
		if ( $board_config['allow_bbcode'] && $bbcode_uid != '' )
		{
			$message = bbencode_second_pass($message, $bbcode_uid);
		}
		$message = make_clickable($message);

		//
		// Parse smilies
		//
		if ( $board_config['allow_smilies'] && $row['enable_smilies'] )
		{
			$message = smilies_pass($message);
		}

		//
		// Highlight active words (primarily for search)
		//
		if ($highlight_match)
		{
			// This was shamelessly 'borrowed' from volker at multiartstudio dot de
			// via php.net's annotated manual
			$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));
		}

		//
		// Replace naughty words
		//
		if (count($orig_word))
		{
			$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);

			$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
		}

		//
		// Replace newlines (we use this rather than nl2br because
		// till recently it wasn't XHTML compliant)
		//
		$message = str_replace("\n", "\n<br />\n", $message);

		$template->assign_block_vars('stickypost', array(
			'DATE' => $post_date,
			'MESSAGE' => $message,
			'POSTER' => $poster,
			'POSTER_PROFILE' => $poster_profile
		));
	}
}


#
#-----[ OPEN ]---------------------------------
#
templates/subSilver/viewtopic_body.tpl

#
#-----[ FIND ]---------------------------------
#
	{POLL_DISPLAY} 

#
#-----[ AFTER, ADD ]---------------------------------
#
	<!-- BEGIN stickypost -->
	<tr>
		<td class="row2" colspan="2"><div class="gen">
		{stickypost.MESSAGE}</div>___________
		<div class="gensmall">{stickypost.POSTER_PROFILE} @ {stickypost.DATE}</div>
		</td>
	</tr>
	<!-- END stickypost -->

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
I hope this can be usefull to someone...

Thanks for this! I never could make something like this by my self without your MOD. If some detail is needed, just ask.

Bye.-
...maybe if I try with the other eye...
trv
Registered User
Posts: 64
Joined: Sun Nov 07, 2004 4:39 pm

Post by trv »

Has anyone tested the above mod? does it work with phpbb 2.0.19 ?

And furthermore, does it work with CH 2.1.4 ?

EDIT-->

Tested, the code works! The mod is awesome.

I changed it a little bit so as to work with Categories Hierarchy 2.1.4, i can post the code if asked.
Post Reply

Return to “[2.0.x] MODs in Development”