News:

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

Main Menu

Template parse error

Started by McDevil™, September 01, 2014, 06:40:22 PM

Previous topic - Next topic

McDevil™

function template_body_above()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

   echo '
   <div id="bodybg">
      <div class="wrapper">
         <div id="hdr-l">
            <div id="hdr-r">
               <div id="header">
                  <div id="time">
                     ', $context['current_time'],'
                  </div>
                  <div id="searcharea">
                     <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
                        <input type="text" name="search" value="', $txt['search'], '..." onfocus="this.value = \'\';" onblur="if(this.value==\'\') this.value=\'', $txt['search'], '...\';" /> ';

                        // Search within current topic?
                        if (!empty($context['current_topic']))
                        echo '
                           <input type="hidden" name="topic" value="', $context['current_topic'], '" />';

                        // If we're on a certain board, limit it to this board ;).
                        elseif (!empty($context['current_board']))
                        echo '
                           <input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';

                  echo '
                     </form>
                  </div>
                  <a href="'.$scripturl.'" title=""><span id="logo">&nbsp;</span></a>
               </div>
               <div id="toolbar">
                  ',template_menu(),'
               </div>
               <div id="bnr">
                  <div id="userarea">';
                     if (!empty($context['user']['avatar']))
                     echo '<div id="db-avatar">'.$context['user']['avatar']['image'].'</div>';

                     if ($context['user']['is_logged'])
                     {
                     echo '
                        <ul>
                           <li><b>', $txt['hello_member'], ' ', $context['user']['name'],'</b></li>';

                           // Only tell them about their messages if they can read their messages!
                           if ($context['allow_pm'])
                           echo '<li>' ,$txt['msg_alert_you_have'], ' <a href="', $scripturl, '?action=pm">', $context['user']['messages'], ' ', $context['user']['messages'] != 1 ? $txt['msg_alert_messages'] : $txt['message_lowercase'], '</a>', $txt['newmessages4'], ' ', $context['user']['unread_messages'], ' ', $context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1'] , '.</li>';

                           // Is the forum in maintenance mode?
                           if ($context['in_maintenance'] && $context['user']['is_admin'])
                           echo '<li><b>', $txt['maintain_mode_on'], '</b></li>';

                           // Are there any members waiting for approval?
                           if (!empty($context['unapproved_members']))
                           echo '<li>', $context['unapproved_members'] == 1 ? $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="', $scripturl, '?action=admin;area=viewmembers;sa=browse;type=approve">', $context['unapproved_members'] == 1 ? $txt['approve_member'] : $context['unapproved_members'] . ' ' . $txt['approve_members'], '</a> ', $txt['approve_members_waiting'], '</li>';

                           echo '
                  <li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';
if (!empty($context['user']['total_time_logged_in']))
{
echo '
<li>', $txt['totalTimeLogged1'];

// If days is just zero, don't bother to show it.
if ($context['user']['total_time_logged_in']['days'] > 0)
echo $context['user']['total_time_logged_in']['days'] . $txt['totalTimeLogged2'];

// Same with hours - only show it if it's above zero.
if ($context['user']['total_time_logged_in']['hours'] > 0)
echo $context['user']['total_time_logged_in']['hours'] . $txt['totalTimeLogged3'];

// But, let's always show minutes - Time wasted here: 0 minutes ;).
echo $context['user']['total_time_logged_in']['minutes'], $txt['totalTimeLogged4'], '<br /></li>'
                 
                     }

                        </ul>';
                     }

                     // Otherwise they're a guest - this time ask them to either register or login - lazy bums...
                     else
                     {
                     echo '
                        <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
                           <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '"  style="margin: 0px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
                              <b>', $txt['username'], ':</b><br />
                              <input class="loginput" type="text" name="user" size="17" /><br/>
                              <b>', $txt['password'], ':</b><br />
                              <input class="loginput" type="password" name="passwrd" size="17" />
                              <input class="logbutton" type="submit" value="', $txt['login'], '" /><br />
                              <input type="hidden" name="hash_passwrd" value="" /></form>';
                     }
               echo '
                  </div>
               </div>
            </div>
         </div>
         <div id="bdy-l">
            <div id="bdy-r">
               <div id="bdy-tl">
                  <div id="bdy-tr">
                     <div id="bodyarea">';

                        // Show the navigation tree.
                        theme_linktree();
}


Can you tell me whats wrong here?
I was trying to put Total Time on forums but I got error Template parse error
Some error in 247 line.
Pls I want to see how much did i spent on forum.
Help me!
Can you give me something for Total time on forum?

Deaks

seems you missed an echo'

try this

function template_body_above()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

   echo '
   <div id="bodybg">
      <div class="wrapper">
         <div id="hdr-l">
            <div id="hdr-r">
               <div id="header">
                  <div id="time">
                     ', $context['current_time'],'
                  </div>
                  <div id="searcharea">
                     <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
                        <input type="text" name="search" value="', $txt['search'], '..." onfocus="this.value = \'\';" onblur="if(this.value==\'\') this.value=\'', $txt['search'], '...\';" /> ';

                        // Search within current topic?
                        if (!empty($context['current_topic']))
                        echo '
                           <input type="hidden" name="topic" value="', $context['current_topic'], '" />';

                        // If we're on a certain board, limit it to this board ;).
                        elseif (!empty($context['current_board']))
                        echo '
                           <input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';

                  echo '
                     </form>
                  </div>
                  <a href="'.$scripturl.'" title=""><span id="logo">&nbsp;</span></a>
               </div>
               <div id="toolbar">
                  ',template_menu(),'
               </div>
               <div id="bnr">
                  <div id="userarea">';
                     if (!empty($context['user']['avatar']))
                     echo '<div id="db-avatar">'.$context['user']['avatar']['image'].'</div>';

                     if ($context['user']['is_logged'])
                     {
                     echo '
                        <ul>
                           <li><b>', $txt['hello_member'], ' ', $context['user']['name'],'</b></li>';

                           // Only tell them about their messages if they can read their messages!
                           if ($context['allow_pm'])
                           echo '<li>' ,$txt['msg_alert_you_have'], ' <a href="', $scripturl, '?action=pm">', $context['user']['messages'], ' ', $context['user']['messages'] != 1 ? $txt['msg_alert_messages'] : $txt['message_lowercase'], '</a>', $txt['newmessages4'], ' ', $context['user']['unread_messages'], ' ', $context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1'] , '.</li>';

                           // Is the forum in maintenance mode?
                           if ($context['in_maintenance'] && $context['user']['is_admin'])
                           echo '<li><b>', $txt['maintain_mode_on'], '</b></li>';

                           // Are there any members waiting for approval?
                           if (!empty($context['unapproved_members']))
                           echo '<li>', $context['unapproved_members'] == 1 ? $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="', $scripturl, '?action=admin;area=viewmembers;sa=browse;type=approve">', $context['unapproved_members'] == 1 ? $txt['approve_member'] : $context['unapproved_members'] . ' ' . $txt['approve_members'], '</a> ', $txt['approve_members_waiting'], '</li>';

                           echo '
                 <li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';
}
echo'
                        </ul>';
                     }

                     // Otherwise they're a guest - this time ask them to either register or login - lazy bums...
                     else
                     {
                     echo '
                        <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
                           <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '"  style="margin: 0px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
                              <b>', $txt['username'], ':</b><br />
                              <input class="loginput" type="text" name="user" size="17" /><br/>
                              <b>', $txt['password'], ':</b><br />
                              <input class="loginput" type="password" name="passwrd" size="17" />
                              <input class="logbutton" type="submit" value="', $txt['login'], '" /><br />
                              <input type="hidden" name="hash_passwrd" value="" /></form>';
                     }
               echo '
                  </div>
               </div>
            </div>
         </div>
         <div id="bdy-l">
            <div id="bdy-r">
               <div id="bdy-tl">
                  <div id="bdy-tr">
                     <div id="bodyarea">';

                        // Show the navigation tree.
                        theme_linktree();
}
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

McDevil™

I changed a bit,so can you check again?
Because I forget to put something.

I forget to put this
<li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';
if (!empty($context['user']['total_time_logged_in']))
{
echo '
<li>', $txt['totalTimeLogged1'];

// If days is just zero, don't bother to show it.
if ($context['user']['total_time_logged_in']['days'] > 0)
echo $context['user']['total_time_logged_in']['days'] . $txt['totalTimeLogged2'];

// Same with hours - only show it if it's above zero.
if ($context['user']['total_time_logged_in']['hours'] > 0)
echo $context['user']['total_time_logged_in']['hours'] . $txt['totalTimeLogged3'];

// But, let's always show minutes - Time wasted here: 0 minutes ;).
echo $context['user']['total_time_logged_in']['minutes'], $txt['totalTimeLogged4'], '<br /></li>';
}

Deaks

ok see that code you just posted after the } at the end add echo'
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

McDevil™

I have some </ul>';
What to do with that?

Deaks

leave it :)

the echo' should go between the } and <ul>';
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

McDevil™

Again some error but now on 246 line.
Whats now?
Thank you for your help.
but I dont get it,whats now?

Deaks

ok post exactly what you have please
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

McDevil™

function template_body_above()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

   echo '
   <div id="bodybg">
      <div class="wrapper">
         <div id="hdr-l">
            <div id="hdr-r">
               <div id="header">
                  <div id="time">
                     ', $context['current_time'],'
                  </div>
                  <div id="searcharea">
                     <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
                        <input type="text" name="search" value="', $txt['search'], '..." onfocus="this.value = \'\';" onblur="if(this.value==\'\') this.value=\'', $txt['search'], '...\';" /> ';

                        // Search within current topic?
                        if (!empty($context['current_topic']))
                        echo '
                           <input type="hidden" name="topic" value="', $context['current_topic'], '" />';

                        // If we're on a certain board, limit it to this board ;).
                        elseif (!empty($context['current_board']))
                        echo '
                           <input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';

                  echo '
                     </form>
                  </div>
                  <a href="'.$scripturl.'" title=""><span id="logo">&nbsp;</span></a>
               </div>
               <div id="toolbar">
                  ',template_menu(),'
               </div>
               <div id="bnr">
                  <div id="userarea">';
                     if (!empty($context['user']['avatar']))
                     echo '<div id="db-avatar">'.$context['user']['avatar']['image'].'</div>';

                     if ($context['user']['is_logged'])
                     {
                     echo '
                        <ul>
                           <li><b>', $txt['hello_member'], ' ', $context['user']['name'],'</b></li>';

                           // Only tell them about their messages if they can read their messages!
                           if ($context['allow_pm'])
                           echo '<li>' ,$txt['msg_alert_you_have'], ' <a href="', $scripturl, '?action=pm">', $context['user']['messages'], ' ', $context['user']['messages'] != 1 ? $txt['msg_alert_messages'] : $txt['message_lowercase'], '</a>', $txt['newmessages4'], ' ', $context['user']['unread_messages'], ' ', $context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1'] , '.</li>';

                           // Is the forum in maintenance mode?
                           if ($context['in_maintenance'] && $context['user']['is_admin'])
                           echo '<li><b>', $txt['maintain_mode_on'], '</b></li>';

                           // Are there any members waiting for approval?
                           if (!empty($context['unapproved_members']))
                           echo '<li>', $context['unapproved_members'] == 1 ? $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="', $scripturl, '?action=admin;area=viewmembers;sa=browse;type=approve">', $context['unapproved_members'] == 1 ? $txt['approve_member'] : $context['unapproved_members'] . ' ' . $txt['approve_members'], '</a> ', $txt['approve_members_waiting'], '</li>';

                           echo '
                              <li><a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a></li>
                              <li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';
if (!empty($context['user']['total_time_logged_in']))
{
echo '
<li>', $txt['totalTimeLogged1'];

// If days is just zero, don't bother to show it.
if ($context['user']['total_time_logged_in']['days'] > 0)
echo $context['user']['total_time_logged_in']['days'] . $txt['totalTimeLogged2'];

// Same with hours - only show it if it's above zero.
if ($context['user']['total_time_logged_in']['hours'] > 0)
echo $context['user']['total_time_logged_in']['hours'] . $txt['totalTimeLogged3'];

// But, let's always show minutes - Time wasted here: 0 minutes ;).
echo $context['user']['total_time_logged_in']['minutes'], $txt['totalTimeLogged4'], '<br /></li>';
}
                echo'
                     </ul>';
                     }

                     // Otherwise they're a guest - this time ask them to either register or login - lazy bums...
                     else
                     {
                     echo '
                        <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
                           <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '"  style="margin: 0px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
                              <b>', $txt['username'], ':</b><br />
                              <input class="loginput" type="text" name="user" size="17" /><br/>
                              <b>', $txt['password'], ':</b><br />
                              <input class="loginput" type="password" name="passwrd" size="17" />
                              <input class="logbutton" type="submit" value="', $txt['login'], '" /><br />
                              <input type="hidden" name="hash_passwrd" value="" />
                           </form>';
                     }
               echo '
                  </div>
               </div>
            </div>
         </div>
         <div id="bdy-l">
            <div id="bdy-r">
               <div id="bdy-tl">
                  <div id="bdy-tr">
                     <div id="bodyarea">';

                        // Show the navigation tree.
                        theme_linktree();
}

Here you go.
I have like this.

McDevil™

Does anyone know solution to this?
I really want to see Total time on the index.
I dont want to go to statistics and then see or whatever.

Deaks

dude please dont bump after 16 mins I am busy elsewhere and other people will be doing other things ... patience my friend :)
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

McDevil™

I know,but there is other supporters or whatever is called that,right?
Sorry about that.
But I want to finish my forum as fast as I can and this is a issue that I deal with.
Sorry again.
And I am new to this forum.

Deaks

you are right their are others who are all doing their own thing or helping someone else, I know you want done and I personally want rid of you for now (in good sense as it would mean your issue is resolved).

Still need wee bit of patience ... it will help you more aswell promise :)

Anyway im off for some coffee and if no-one has got to you ill look at code again when I return :)
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

Arantor

It's really not very nice to bump people provide support here since everyone supporting here is doing it in their spare time. Every person who provides help here is doing it instead of having fun or watching the game or whatever they might otherwise do. While I sympathise with your desire to launch, the reality is that people help when they can if they can.

Using $context['user']['total_time_logged_in']['minutes'] isn't going to work. It only shows the minutes, not a total, so you either need to convert the rest of $context['user']['total_time_logged_in'] into minutes or output the rest of it.

Though I'm not sure how much benefit it is to users to see how much time they've spent on your site... I certainly don't look how much time I've spent here because the number would probably upset me (and it's wildly inaccurate in my case too)

McDevil™

Because I have SA:MP server that needs a forum.
And I want to have that little decoration.
On default smf theme,that code was working and when I switch to another theme,it does not.

bv-rpsamp.netau.net/index.php
Thats my forum.Its on croatian if you dont know.
Its darkbase_a20 theme,something like that.

Advertisement: