Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: richwig83 - helmikuu 13, 2014, 08:04:04 AP

Otsikko: Flagrant by Crip - A few edits i need help with
Kirjoitti: richwig83 - helmikuu 13, 2014, 08:04:04 AP
Hi.

Im wondering if anyone can help me take a few items out of the standard menu bar as it comes standard. I managed to do it very easily on Crips Recursive theme runining v1.1.19... but this one on v2 is proving a little more complicated.

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

   echo '
      <div id="topnav">
         <ul>';

   foreach ($context['menu_buttons'] as $act => $button)
   {
      echo '
            <li id="button_', $act, '">
            <a class="', $button['active_button'] ? 'active ' : '', '" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '><span>', $button['title'], '</span></a>';

      if (!empty($button['sub_buttons']))
      {
         echo '
               <ul>';

         foreach ($button['sub_buttons'] as $childbutton)
         {
            echo '
                  <li>
                     <a href="', $childbutton['href'], '"', isset($childbutton['target']) ? ' target="' . $childbutton['target'] . '"' : '', '>', $childbutton['title'], !empty($childbutton['sub_buttons']) ? '...' : '', '</a>';

            // 3rd level menus :)
            if (!empty($childbutton['sub_buttons']))
            {
               echo '
                     <ul>';

               foreach ($childbutton['sub_buttons'] as $grandchildbutton)
                  echo '
                        <li>
                           <a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>', $grandchildbutton['title'], '</a>
                        </li>';

               echo '
                  </ul>';
            }

            echo '
                  </li>';
         }
         echo '
               </ul>';
      }
      echo '
            </li>';
   }

   echo '
         </ul>
      </div><br class="clear" />';
}

// Generate a strip of buttons.
function template_button_strip($button_strip, $direction = 'top', $strip_options = array())
{
   global $settings, $context, $txt, $scripturl;

   if (!is_array($strip_options))
      $strip_options = array();

   // List the buttons in reverse order for RTL languages.
   if ($context['right_to_left'])
      $button_strip = array_reverse($button_strip, true);

   // Create the buttons...
   $buttons = array();
   foreach ($button_strip as $key => $value)
   {
      if (!isset($value['test']) || !empty($context[$value['test']]))
         $buttons[] = '
            <li><a' . (isset($value['id']) ? ' id="button_strip_' . $value['id'] . '"' : '') . ' class="button_strip_' . $key . (isset($value['active']) ? ' active' : '') . '" href="' . $value['url'] . '"' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '><span>' . $txt[$value['text']] . '</span></a></li>';
   }

   // No buttons? No button strip either.
   if (empty($buttons))
      return;

   // Make the last one, as easy as possible.
   $buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]);

   echo '
      <div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"': ''), '>
         <ul>',
            implode('', $buttons), '
         </ul>
      </div>';
}

?>



Any help would be most welcome.

Thanks
Rich
Otsikko: Re: Flagrant by Crip - Menu editing
Kirjoitti: Branko. - helmikuu 13, 2014, 08:14:43 AP
Ask HERE (http://www.simplemachines.org/community/index.php?topic=296963.0)
Otsikko: Re: Flagrant by Crip - Menu editing
Kirjoitti: richwig83 - helmikuu 13, 2014, 08:14:59 AP
Ahh... sorted. subs.php...

Removed..

),
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => true,
'sub_buttons' => array(
),


Rich
Otsikko: Re: Flagrant by Crip - Menu editing
Kirjoitti: kat - helmikuu 13, 2014, 08:19:11 AP
For reference, you don't need to remove anything.

If you change:

'show' => true,

to

'show' => false,

it won't show. :)

Otsikko: Re: Flagrant by Crip - Menu editing
Kirjoitti: richwig83 - helmikuu 13, 2014, 08:24:11 AP
Brilliant. Thanks very much for your quick response.
"
Im also wanting to add a PM count and unread post count to the "userarea". Is that a simple fix?
Otsikko: Re: Flagrant by Crip - A few edits i need help with
Kirjoitti: kat - helmikuu 13, 2014, 08:29:06 AP
I believe the actual coding's not too difficult. But, I'd imagine that such things would increase your load and slow your forum down, quite considerably.

I'd be entirely happy for someone to tell me I'm wrong, about that, though. :)
Otsikko: Re: Flagrant by Crip - A few edits i need help with
Kirjoitti: richwig83 - helmikuu 13, 2014, 09:24:00 AP
Ok thanks for your advice. That is definitely something we want to avoid.
Otsikko: Re: Flagrant by Crip - A few edits i need help with
Kirjoitti: IchBin™ - helmikuu 14, 2014, 05:44:36 IP
You don't even need to change a source file for this. You can unset() or change the 'show' = false for the help button in the template_menu() function if you want to. Although, this only does it per theme. :)