News:

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

Main Menu

[FREE] Button help

Started by Tommiiee, November 22, 2010, 12:43:54 PM

Previous topic - Next topic

Tommiiee

Hi everyone,

I'm using the Esintiler theme. The theme doesn't use images for buttons like 'new thread', 'new poll', 'mark as read', etc.
But I'd like buttons instead of text.

I've been doing a bit of research, but I can't figure out how to implement my images.

Can somebody help me out? :)
Shouldn't be too hard for the experts around here. :P

Thanks,
Tom

Kays

Hi, which version SMF? ???

For 1.1 the original themes (Classic and Babylon) used images and this was included in the code for the buttons. It's still there (but not used) for the Core theme, but no longer exists for 2.0


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Tommiiee

I'm so sorry I forgot to mention that.

I'm using SMF 1.1.12 :)

Kays

Cool, that should make it easier since you should have the older themes to refer to.

For a start the images (buttons) should go into the Images folder of that theme in a folder with the language name. (ie: themes/Esintiler/images/English) Look at the Babylon theme for an example.

In Display.template.php look for the following:


$normal_buttons = array(
'reply' => array('test' => 'can_reply', 'text' => 146, 'image' => 'reply.gif', 'lang' => true, 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';num_replies=' . $context['num_replies']),
'notify' => array('test' => 'can_mark_notify', 'text' => 125, 'image' => 'notify.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_topic'] : $txt['notification_enable_topic']) . '\');"', 'url' => $scripturl . '?action=notify;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']),
'custom' => array(),
'send' => array('test' => 'can_send_topic', 'text' => 707, 'image' => 'sendtopic.gif', 'lang' => true, 'url' => $scripturl . '?action=sendtopic;topic=' . $context['current_topic'] . '.0'),
'print' => array('text' => 465, 'image' => 'print.gif', 'lang' => true, 'custom' => 'target="_blank"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'),
);

// Special case for the custom one.
if ($context['user']['is_logged'] && $settings['show_mark_read'])
$normal_buttons['custom'] = array('text' => 'mark_unread', 'image' => 'markunread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']);
elseif ($context['can_add_poll'])
$normal_buttons['custom'] = array('text' => 'add_poll', 'image' => 'add_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']);
else
unset($normal_buttons['custom']);


And check that each line includes the image. For example in the first line 'image' => 'reply.gif'. Also check that the image names match your images.

Then in index.template. Make sure the following is set to true


/* Use plain buttons - as oppossed to text buttons? */
$settings['use_buttons'] = true;


Finally, at the bottom of the page look for:


elseif (!isset($buttons[$key]) || $force_reset)
$buttons[$key] = '<a href="' . $value['url'] . '" ' .( isset($value['custom']) ? $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>';


And replace it with:

elseif (!isset($buttons[$key]) || $force_reset)
$buttons[$key] = '<a href="' . $value['url'] . '" ' .( isset($value['custom']) ? $value['custom'] : '') . '>' . ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . ($value['lang'] ? $context['user']['language'] . '/' : '') . $value['image'] . '" alt="' . $txt[$value['text']] . '" border="0" />' : $txt[$value['text']]) . '</a>';


The extra bit of code in there is what makes the images show.




If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Tommiiee

Works like a charm! Thank you SO much!

You explained very clearly :) People like you make this community strong!

Thanks again.

Tom

Kays

Great. The last time I tried to explain this it didn't quite go as well. ::)

Marking this as solved and moving it to the SMF Coding Discussion board.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Advertisement: