i found variable $site_fields ,$site_html in the page.tpl.php .according to drupal theme convention,if in the tpl.php file,we use a variable,there must be a function in template.php to deal with it. but in garland theme i can't find the function which deal with the variable $site_fields ,$site_html ....any tips would be appreciated.

Comments

yelvington’s picture

Those are not provided to page.tpl.php. They are created inside of Garland's page.tpl.php.

        <?php
          // Prepare header
          $site_fields = array();
          if ($site_name) {
            $site_fields[] = check_plain($site_name);
          }
          if ($site_slogan) {
            $site_fields[] = check_plain($site_slogan);
          }
          $site_title = implode(' ', $site_fields);
          if ($site_fields) {
            $site_fields[0] = '<span>'. $site_fields[0] .'</span>';
          }
          $site_html = implode(' ', $site_fields);

          if ($logo || $site_title) {
            print '<h1><a href="'. check_url($front_page) .'" title="'. $site_title .'">';
            if ($logo) {
              print '<img src="'. check_url($logo) .'" alt="'. $site_title .'" id="logo" />';
            }
            print $site_html .'</a></h1>';
          }
        ?>
runeveryday’s picture

$site_fields this is a new variable. not available in page.tpl.php. i can't understand about your said. i know you listing code is in page.tpl.php. but a new variable must be by template.php registered. am i right ?

oopsies’s picture

It is in page.tpl.php. $site_fields and $site_html are being defined as you go along. Here's where they are each defined:

          $site_fields = array();

          $site_html = implode(' ', $site_fields);

See, $site_fields is being defined as an array and $site_html is the result of joining all the values in the $site_fields array with no delimiters.

runeveryday’s picture

thank you very much,but according to " but to keep the .tpl.php files tidy it can be used to hold preprocessors for generating variables before they are merged with the markup inside .tpl.php files. " why,there is no preprocessors for generating the two above variables .

oopsies’s picture

I think the main problem is that you don't really know how to program in PHP? You should read up on some programming - it will definitely help you with this because you are asking questions that are basic to programming. PHP is the "pre-processor" that the quote is referring to. The parts I quoted earlier shows when the variable is being created. The variable doesn't exist until that part of the code. Alternatively, don't theme with Garland. Try a simpler one such as Bluemarine and slowly work your way up in difficulty.