Removing "mark read" as a button

Started by dopeitspaul, September 19, 2014, 05:46:15 PM

Previous topic - Next topic

dopeitspaul

Hey everyone, I need help trying to remove the mark read button on the messageindex.template. I want to move it away from the "new topic" and "new poll" button. And just make the "mark read" a link instead. Similar to the "go down" link.

Here's an image of my message index


Anyway of making this happen? thanks!

Gwenwyfar

That should be done by the css. The button is already a link, but it is styled to look like a button. Each button has an unique class as well, so you don't need to change anything in your template.

You can use inspect element in chrome or firefox to help you out.
"It is impossible to communicate with one that does not wish to communicate"

dopeitspaul

Quote from: Fortytwo on September 20, 2014, 01:25:40 AM
That should be done by the css. The button is already a link, but it is styled to look like a button. Each button has an unique class as well, so you don't need to change anything in your template.

You can use inspect element in chrome or firefox to help you out.

I tried editing the buttons on the css. But it affects the "New Topic" and "New Poll" button too. I'm trying to keep those as a button. But I'm trying to make remove the "Mark Read" as a button and give it it's own style.

dopeitspaul

I'm trying to make it look like this.



Note: this is just a sample. The "mark all read" isn't a link. Just a text to show you guys how I want it to turn out.

Gwenwyfar

Hard to help with an actual code when I know nothing of how the css is in your site, but you can try adding the following in your css, on all the places where there is code for the buttonlist, though I'm assuming your theme still has that default class in it :

:not(.button_strip_markread)

If you can't figure how that works, please copy paste the parts of your css with buttonlist involved.
"It is impossible to communicate with one that does not wish to communicate"

Antechinus

It's possible, but slightly tricky. The array is defined here in MessageIndex.template.php:

// Create the button set...
$normal_buttons = array(
'new_topic' => array('test' => 'can_post_new', 'text' => 'new_topic', 'image' => 'new_topic.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true),
'post_poll' => array('test' => 'can_post_poll', 'text' => 'new_poll', 'image' => 'new_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'),
'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : ''). 'notify.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_board'] : $txt['notification_enable_board']) . '\');"', 'url' => $scripturl . '?action=notifyboard;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';board=' . $context['current_board'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
'markread' => array('text' => 'mark_read_short', 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']),
);

// They can only mark read if they are logged in and it's enabled!
if (!$context['user']['is_logged'] || !$settings['show_mark_read'])
unset($normal_buttons['markread']);


What you need to do is delete that one from the array, then write custom code for your new link. This should work as a starting point:

// Create the button set...
$normal_buttons = array(
'new_topic' => array('test' => 'can_post_new', 'text' => 'new_topic', 'image' => 'new_topic.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true),
'post_poll' => array('test' => 'can_post_poll', 'text' => 'new_poll', 'image' => 'new_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'),
'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : ''). 'notify.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_board'] : $txt['notification_enable_board']) . '\');"', 'url' => $scripturl . '?action=notifyboard;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';board=' . $context['current_board'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
);

// They can only mark read if they are logged in and it's enabled!
if ($context['user']['is_logged'] && $settings['show_mark_read'])
echo ' <a href="', $scripturl, '?action=markasread;sa=board;board=', $context['current_board'], '.0;', $context['session_var'], '=', $context['session_id'], '">', $txt['mark_read_short'], '</a>';


Try that and see if I screwed anything up. :D

(make backup first)

dopeitspaul

Quote from: Antechinus on September 20, 2014, 04:11:08 AM
It's possible, but slightly tricky. The array is defined here in MessageIndex.template.php:

// Create the button set...
$normal_buttons = array(
'new_topic' => array('test' => 'can_post_new', 'text' => 'new_topic', 'image' => 'new_topic.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true),
'post_poll' => array('test' => 'can_post_poll', 'text' => 'new_poll', 'image' => 'new_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'),
'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : ''). 'notify.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_board'] : $txt['notification_enable_board']) . '\');"', 'url' => $scripturl . '?action=notifyboard;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';board=' . $context['current_board'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
'markread' => array('text' => 'mark_read_short', 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']),
);

// They can only mark read if they are logged in and it's enabled!
if (!$context['user']['is_logged'] || !$settings['show_mark_read'])
unset($normal_buttons['markread']);


What you need to do is delete that one from the array, then write custom code for your new link. This should work as a starting point:

// Create the button set...
$normal_buttons = array(
'new_topic' => array('test' => 'can_post_new', 'text' => 'new_topic', 'image' => 'new_topic.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true),
'post_poll' => array('test' => 'can_post_poll', 'text' => 'new_poll', 'image' => 'new_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'),
'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : ''). 'notify.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_board'] : $txt['notification_enable_board']) . '\');"', 'url' => $scripturl . '?action=notifyboard;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';board=' . $context['current_board'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
);

// They can only mark read if they are logged in and it's enabled!
if ($context['user']['is_logged'] && $settings['show_mark_read'])
echo ' <a href="', $scripturl, '?action=markasread;sa=board;board=', $context['current_board'], '.0;', $context['session_var'], '=', $context['session_id'], '">', $txt['mark_read_short'], '</a>';


Try that and see if I screwed anything up. :D

(make backup first)

Sorry, nothing happened. The mark read button just disappeared was all.

Antechinus

Try this for the conditional:

if ($context['user']['is_logged'] || $settings['show_mark_read'])

dopeitspaul

Quote from: Antechinus on September 22, 2014, 04:53:36 PM
Try this for the conditional:

if ($context['user']['is_logged'] || $settings['show_mark_read'])

Sorry, didn't work  :-\

Antechinus

Oh bugger. You mean I'll actually have to test it? :D

Ok, will take a look tonight if nobody beats me to it.

dopeitspaul

Quote from: Antechinus on September 22, 2014, 05:51:52 PM
Oh bugger. You mean I'll actually have to test it? :D

Ok, will take a look tonight if nobody beats me to it.

Thanks for the help. Appreciate it.

Please let me know if you can find a way! If not, it's ok

Antechinus

Yokay. Here ya go.

Find this lot:

// Create the button set...
$normal_buttons = array(
'new_topic' => array('test' => 'can_post_new', 'text' => 'new_topic', 'image' => 'new_topic.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true),
'post_poll' => array('test' => 'can_post_poll', 'text' => 'new_poll', 'image' => 'new_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'),
'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : ''). 'notify.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_board'] : $txt['notification_enable_board']) . '\');"', 'url' => $scripturl . '?action=notifyboard;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';board=' . $context['current_board'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
'markread' => array('text' => 'mark_read_short', 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']),
);

// They can only mark read if they are logged in and it's enabled!
if (!$context['user']['is_logged'] || !$settings['show_mark_read'])
unset($normal_buttons['markread']);

// Allow adding new buttons easily.
call_integration_hook('integrate_messageindex_buttons', array(&$normal_buttons));

if (!$context['no_topic_listing'])
{
echo '
<div class="pagesection">
<div class="pagelinks floatleft">', $txt['pages'], ': ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '&nbsp;&nbsp;<a href="#bot"><strong>' . $txt['go_down'] . '</strong></a>' : '', '</div>
', template_button_strip($normal_buttons, 'right'), '
</div>';



Is no good. You want something else. Ok, so replace with this stuff here:

// Create the button set...
$normal_buttons = array(
'new_topic' => array('test' => 'can_post_new', 'text' => 'new_topic', 'image' => 'new_topic.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true),
'post_poll' => array('test' => 'can_post_poll', 'text' => 'new_poll', 'image' => 'new_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'),
'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : ''). 'notify.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_board'] : $txt['notification_enable_board']) . '\');"', 'url' => $scripturl . '?action=notifyboard;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';board=' . $context['current_board'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
);

// Allow adding new buttons easily.
call_integration_hook('integrate_messageindex_buttons', array(&$normal_buttons));

if (!$context['no_topic_listing'])
{
echo '
<div class="pagesection">
<div class="pagelinks floatleft">', $txt['pages'], ': ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '&nbsp;&nbsp;<a href="#bot"><strong>' . $txt['go_down'] . '</strong></a>' : '', '</div>
', template_button_strip($normal_buttons, 'right');


// They can only mark read if they are logged in and it's enabled!
if ($context['user']['is_logged'] && $settings['show_mark_read'])
echo ' <a href="', $scripturl, '?action=markasread;sa=board;board=', $context['current_board'], '.0;', $context['session_var'], '=', $context['session_id'], '" class="custom_mark_read">', $txt['mark_read_short'], '</a>';

echo '
</div>';



Then you need some CSS, so add this anywhere in index.css:

.custom_mark_read {
float: right;
clear: right;
margin: 1em 0.5em 0 0;
font-weight: bold;
}



Play with the CSS until you're happy. You can also use the same template tricks (with very slight adaptions) for the unread posts and new replies pages if you like. The same CSS class will work on all of them if you have it in the markup.

dopeitspaul

Thank you it worked.

I'm still debating whether or not I want to do the same thing for the buttons on the topic page. If anything, I'll get back to you.

Advertisement: