Advertisement:

Author Topic: Settings in template files  (Read 8312 times)

Offline Deaks

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,147
  • Gender: Male
Settings in template files
« 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.

Code: [Select]
                <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.

Code: [Select]
<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()"

Code: [Select]
        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:

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

Code: [Select]
',   empty($context['header_logo_url_html_safe'])
is paired   with
Code: [Select]
array(
            'id' => 'header_logo_url',
              'label' => $txt['header_logo_url'],
              'description' => $txt['header_logo_url_desc'],
            'type'   => 'text',
        ),
and finally for this example:
Code: [Select]
              ', 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
Code: [Select]
        array(
            'id' =>   'site_slogan',
            'label' => $txt['site_slogan'],
              'description' => $txt['site_slogan_desc'],
              'type' => 'text',
        ),

If we were to remove   all three

Code: [Select]
<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...
Code: [Select]
$settings['site_slogan']
Code: [Select]
$settings['forum_width']
Code: [Select]
$context['header_logo_url_html_safe']
I   also removed the code that was not needed anymore

If you have any questions please ask.
« Last Edit: August 02, 2010, 11:23:46 AM by SlammedDime »

bullbreedluverz

  • Guest
Re: Settings in index.template.php
« Reply #1 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)?


Offline flapjack

  • SMF Hero
  • ******
  • Posts: 2,615
  • Gender: Male
  • I pity the fools!
Re: Settings in index.template.php
« Reply #2 on: July 14, 2010, 10:31:00 PM »
Quote
Will  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

  • Guest
Re: Settings in index.template.php
« Reply #3 on: July 15, 2010, 07:12:43 AM »
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.

Offline Deaks

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,147
  • Gender: Male
Re: Settings in index.template.php
« Reply #4 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

Offline SlammedDime

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,280
  • School of Air Ride
    • matt.zuba on Facebook
    • @mattzuba on Twitter
    • ZubaFitness
Re: Settings in template files
« Reply #5 on: August 02, 2010, 11:25:48 AM »
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...