News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Settings in template files

Started by Runic, July 14, 2010, 07:32:53 PM

Previous topic - Next topic

Deaks

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.
~~~~
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."

bullbreedluverz

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)?


flapjack

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!

bullbreedluverz

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 to add this requirement for theme approvals and a link to this post to give instructions upon doing it.

Deaks

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
~~~~
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."

SlammedDime

This has been added to the theme approval guidelines.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

Advertisement: