Simple Machines Community Forum

Customizing SMF => Graphics and Templates => Topic started by: Deaks on July 14, 2010, 07:32:53 PM

Title: Settings in template files
Post by: Deaks on July 14, 2010, 07:32:53 PM
Over the past few years a lot of themes have been submitted to the theme   site that remove the default coding. Yet, the author doesn't make the   correct changes. This is a guide for customizers for what to do when you   remove the code.


                <a href="',   $scripturl, '">', empty($context['header_logo_url_html_safe']) ?   $context['forum_name'] : '<img src="' .   $context['header_logo_url_html_safe'] . '" alt="' .   $context['forum_name'] . '" />', '</a>


There is a   file called Settings.template.php and like any other template file if   you dont include it the theme uses the default one.

This is an   extract of the Curve code found in SMF 2.

<div   id="wrapper" style="width: ' . $settings['forum_width'] . '">' : '', '
      <div id="header"><div class="frame">
        <div   id="top_section">
            <h1 class="forumtitle">
                  <a href="', $scripturl, '">',   empty($context['header_logo_url_html_safe']) ? $context['forum_name'] :   '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' .   $context['forum_name'] . '" />', '</a>
              </h1>';

    // the upshrink image, right-floated
      echo '
            <img id="upshrink" src="',   $settings['images_url'], '/upshrink.png" alt="*" title="',   $txt['upshrink_description'], '" style="display: none;" />';
      echo '
            ', empty($settings['site_slogan']) ? '<img   id="smflogo" src="' . $settings['images_url'] . '/smflogo.png"   alt="Simple Machines Forum" title="Simple Machines Forum" />' :   '<div id="siteslogan" class="align_right">' .   $settings['site_slogan'] . '</div>', '
        </div>


You   can see the following three functions: width, logo, slogan. They are   located in the Settings.template.php under "function   template_settings()"

        array(
            'id'   => 'header_logo_url',
            'label' =>   $txt['header_logo_url'],
            'description' =>   $txt['header_logo_url_desc'],
            'type' => 'text',
          ),
        array(
            'id' => 'site_slogan',
              'label' => $txt['site_slogan'],
            'description'   => $txt['site_slogan_desc'],
            'type' => 'text',
          ),
        array(
            'id' => 'forum_width',
              'label' => $txt['forum_width'],
              'description' => $txt['forum_width_desc'],
            'type'   => 'text',
            'size' => 8,
        ),


(I   have removed the smileys portion in this code)

So we can see:

width:   ' . $settings['forum_width'] . '
can be paired with
          array(
            'id' => 'forum_width',
              'label' => $txt['forum_width'],
            'description' =>   $txt['forum_width_desc'],
            'type' => 'text',
              'size' => 8,
        ),


',   empty($context['header_logo_url_html_safe'])

is paired   with
array(
            'id' => 'header_logo_url',
              'label' => $txt['header_logo_url'],
              'description' => $txt['header_logo_url_desc'],
            'type'   => 'text',
        ),

and finally for this example:
              ', empty($settings['site_slogan']) ? '<img id="smflogo"   src="' . $settings['images_url'] . '/smflogo.png" alt="Simple Machines   Forum" title="Simple Machines Forum" />' : '<div id="siteslogan"   class="align_right">' . $settings['site_slogan'] . '</div>', '

is   paired with
        array(
            'id' =>   'site_slogan',
            'label' => $txt['site_slogan'],
              'description' => $txt['site_slogan_desc'],
              'type' => 'text',
        ),


If we were to remove   all three

<div id="wrapper">' : '', '
    <div   id="header"><div class="frame">
        <div   id="top_section">
            <h1 class="forumtitle">
                  <a href="', $scripturl,   '">',$context['forum_name'],'</a>
            </h1>';

      // the upshrink image, right-floated
    echo '
              <img id="upshrink" src="', $settings['images_url'], '/upshrink.png"   alt="*" title="', $txt['upshrink_description'], '" style="display:   none;" />';
    echo '
         <img id="smflogo" src="' .   $settings['images_url'] . '/smflogo.png" alt="Simple Machines Forum"   title="Simple Machines Forum" />
        </div>



from   the above I have removed somes  $settings and $context

So...
$settings['site_slogan']
$settings['forum_width']
$context['header_logo_url_html_safe']

I   also removed the code that was not needed anymore

If you have any questions please ask.
Title: Re: Settings in index.template.php
Post by: bullbreedluverz on July 14, 2010, 09:51:00 PM
So if you remove the code from index.template.php you need to remove the corresponding array code from Settings.template.php and add that file in with the custom theme files zip folder?

But why?

You say how to do it but not why you have to, whats wrong/happens if you dont make the necessary edits to Settings.template.php and include it in the theme package?

Will  adding the edited Settings.template.php remove these eliments from the admin panel so that there isn't a defunct input box(es)?

Title: Re: Settings in index.template.php
Post by: flapjack on July 14, 2010, 10:31:00 PM
QuoteWill  adding the edited Settings.template.php remove these eliments from the admin panel so that there isn't a defunct input box(es)?
that's the whole point

thanks Runic, more stuff like this please!
Title: Re: Settings in index.template.php
Post by: bullbreedluverz on July 15, 2010, 07:12:43 AM
Quote from: Runic on July 14, 2010, 07:32:53 PM
Over the past few years a lot of themes have been submitted to the theme   site that remove the default coding. Yet, the author doesn't make the   correct changes.

If there is no written requirement for theme authors to include this file then no1 knows that they should of been including it so no1 will of been including it.
In over a year of making themes I haven't seen this requiremet stated anywhere and no1 from SMF staff have ever said that my themes can't be approved without this file, we can't be expected to make changes that haven't been made clear we should be making.

Maybe an ammendment should be made to the Theme Approval Guidelines (http://www.simplemachines.org/community/index.php?topic=343138.0) to add this requirement for theme approvals and a link to this post to give instructions upon doing it.
Title: Re: Settings in index.template.php
Post by: Deaks on July 15, 2010, 08:09:05 AM
I have already asked for it to be added to theme approval guidelines and hopefully it will be added in next day or two.  I asked SlammedDime yesterday before I posted this topic.

Also the effects are evident you see people saying I have added logo url but its not displaying on my logo isnt displaying on my theme .... etc
Title: Re: Settings in template files
Post by: SlammedDime on August 02, 2010, 11:25:48 AM
This has been added to the theme approval guidelines.