SMF Support > SMF 1.1.x Support
How to catch the last post in Display.template.php?
bedges:
It's a waste of space and bandwidth to have folks reply to a thread by quoting the post previous to theirs, but it's a handy feature for referencing posts farther up the thread. I'm trying to remove the Quote button, but only for the last post in a thread.
I've got Display.template.php open, but I can't find a comparison variable. I see $context['first_message'], but there's no last_message, or last_post, or latest, etc.
Is there an already defined variable I can use?
1.1.9, no mods, custom theme.
Antechinus:
Not as far as I know. I think you would have to create a custom variable to do want you want. Damned fine idea though. I've been half-seriously thinking of completely removing the quote button on the site I co-admin because of the mindless way it gets used.
bedges:
Looks like I have the solution:
Open Sources/Display.php
Find:
--- Code: ---// Get all the important topic info.
--- End code ---
After
--- Code: ---$topicinfo = mysql_fetch_assoc($request);
mysql_free_result($request);
--- End code ---
Insert:
--- Code: ---$context['prefix_lastpost'] = $topicinfo['ID_LAST_MSG'];
--- End code ---
where prefix_ is your own identifier for script modifications.
Open your_theme/Display.template.php
Find:
--- Code: --- // Can they reply? Have they turned on quick reply?
if ($context['can_reply'] && !empty($options['display_quick_reply']))
echo '
<a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';num_replies=', $context['num_replies'], ';sesc=', $context['session_id'], '" onclick="doQuote(', $message['id'], ', \'', $context['session_id'], '\'); return false;">', $reply_button, '</a>';
// So... quick reply is off, but they *can* reply?
elseif ($context['can_reply'])
echo '
<a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';num_replies=', $context['num_replies'], ';sesc=', $context['session_id'], '">', $reply_button, '</a>';
--- End code ---
Replace:
--- Code: --- // Can they reply? Have they turned on quick reply?
if ($context['can_reply'] && !empty($options['display_quick_reply']) && ($message['id'] != $context['prefix_lastpost']))
echo '
<a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';num_replies=', $context['num_replies'], ';sesc=', $context['session_id'], '" onclick="doQuote(', $message['id'], ', \'', $context['session_id'], '\'); return false;">', $reply_button, '</a>';
// So... quick reply is off, but they *can* reply?
elseif ($context['can_reply'] && ($message['id'] != $context['prefix_lastpost']))
echo '
<a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';num_replies=', $context['num_replies'], ';sesc=', $context['session_id'], '">', $reply_button, '</a>';
--- End code ---
Antechinus:
Awesome. Thanks for that. I'll be implementing that straight away. I have a suggestion. Sort it for SMF 2.0 as well then package it as a mod for both versions.
Antechinus:
Just had a pm chat and it's been agreed that I'll package the mod for 1.1.x and 2.0 and credit Bedges for the code. I don't know if anyone else will want such a mod but I think it's a brilliant idea. :)
Navigation
[0] Message Index
[#] Next page
Go to full version