Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: GrahamP - helmikuu 17, 2006, 03:09:15 IP

Otsikko: Undefined error
Kirjoitti: GrahamP - helmikuu 17, 2006, 03:09:15 IP
Help! can someone help a newbie to php, I am trying to add a 'view unread' button between the help and search buttons. In index.template.php I copied the code for the help button and pasted it in then edited the code as follows

Lainaa// Add an unread posts button.
   echo '
                        <a href="', $scripturl, '?action=unread">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/unread.gif" alt="' . $txt[119] . '" border="0" />' : $txt[119]), '</a>', $context['menu_separator'];

The button works ok in that it displays any unread posts but generates errors in the error log at an alarming rate. Is the problem something to do with the global variable $txt?
Otsikko: Re: Undefined error
Kirjoitti: kegobeer - helmikuu 17, 2006, 03:13:33 IP
What version of SMF are you running?
Otsikko: Re: Undefined error
Kirjoitti: GrahamP - helmikuu 17, 2006, 03:22:48 IP
I am running 1.1 RC2
Otsikko: Re: Undefined error
Kirjoitti: kegobeer - helmikuu 17, 2006, 03:23:48 IP
What errors are being logged?
Otsikko: Re: Undefined error
Kirjoitti: GrahamP - helmikuu 17, 2006, 03:50:24 IP
Thanks for the speedy reply, 2 of the error messages below

Doc   Today at 08:47:48 PM 
172.200.27.243     f727f018609e16c946741c3422e5f7f5 
http://reliant3wheelers.co.uk/forum/index.php?topic=2.0 
8: Undefined offset: 135
File: /home/h0mer47/public_html/forum/Themes/classic/Display.template.php (eval?)
Line: 297

   Doc   Today at 08:47:46 PM 
172.200.27.243     f727f018609e16c946741c3422e5f7f5 
http://reliant3wheelers.co.uk/forum/index.php?board=6.0 
8: Undefined offset: 135
File: /home/h0mer47/public_html/forum/Themes/classic/MessageIndex.template.php (eval?)
Line: 297  

the line 297 points to the code I added as in my first post.
Otsikko: Re: Undefined error
Kirjoitti: kegobeer - helmikuu 17, 2006, 04:01:02 IP
Check out this thread for adding menu items to RC2 default theme:

http://www.simplemachines.org/community/index.php?topic=63203.msg%25msg_id%25
Otsikko: Re: Undefined error
Kirjoitti: GrahamP - helmikuu 17, 2006, 04:03:21 IP
Thanks kegobeer will do
Otsikko: Re: Undefined error
Kirjoitti: sm2k - helmikuu 17, 2006, 04:12:44 IP
What's the line immediately above this echo statement?
Otsikko: Re: Undefined error
Kirjoitti: beemer - helmikuu 17, 2006, 04:16:00 IP
Dont know if it matters but

$txt[119])  is the text string for help try  333
Otsikko: Re: Undefined error
Kirjoitti: GrahamP - helmikuu 17, 2006, 04:54:32 IP
Lainaus käyttäjältä: sm2k - helmikuu 17, 2006, 04:12:44 IP
What's the line immediately above this echo statement?

The text from the start of this section is:-

// Show the menu up top.  Something like [home] [help] [profile] [logout]...
function template_menu()
{
   global $context, $settings, $options, $scripturl, $txt;

   // Show the [home] and [help] buttons.
   echo '
            <a href="', $scripturl, '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/home.gif" alt="' . $txt[103] . '" border="0" />' : $txt[103]), '</a>', $context['menu_separator'], '
            <a href="', $scripturl, '?action=help">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/help.gif" alt="' . $txt[119] . '" border="0" />' : $txt[119]), '</a>', $context['menu_separator'];

   // Add an unread posts button.
   echo '
                        <a href="', $scripturl, '?action=unread">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/unread.gif" alt="' . $txt[135] . '" border="0" />' : $txt[119]), '</a>', $context['menu_separator'];

   // How about the [search] button?
   if ($context['allow_search'])
      echo '
            <a href="', $scripturl, '?action=search">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/search.gif" alt="' . $txt[182] . '" border="0" />' : $txt[182]), '</a>', $context['menu_separator'];

I have used green to indicate original code and red for the section I added.
Otsikko: Re: Undefined error
Kirjoitti: GrahamP - helmikuu 17, 2006, 05:38:58 IP
Lainaus käyttäjältä: beemer - helmikuu 17, 2006, 04:16:00 IP
Dont know if it matters but

$txt[119])  is the text string for help try  333
Thanks Beemer did as you suggested and it seems to have done the trick, no more errors atm. Can you tell me where I can find the list of text strings?
Otsikko: Re: Undefined error
Kirjoitti: beemer - helmikuu 17, 2006, 05:47:36 IP
The text strings are in files within the languages folder, just open em have a look and it should make sense  ;)
Otsikko: Re: Undefined error
Kirjoitti: GrahamP - helmikuu 17, 2006, 07:10:07 IP
Thanks again