On 2009-05-15 14:46, Alister Cameron wrote:
Folks,

WordPress has a function that outputs three attributes. It's called language_attributes() and it outputs these three attributes (and their values) for the opening HTML tag.

The code looks like this:

<html xmlns="http://www.w3.org/1999/xhtml"; <?php language_attributes( 'xhtml' ); ?>>

Now, how do you suggest I turn this into TAL?

I can't replace the entire HTML tag coz that will throw a "tag nesting error"...

Do you suggest I drop this function entirely and do it another way, attribute by attribute? Or what?


The right thing to do is writing your own function which returns this attributes as an associative array and then use <tal:attributes>.
You may also use fallback to php:
http://phptal.org/manual/en/split/tales-php.html

The best choice is to write custom pre-filter, which adds those attributes automatically where needed.

Here is the function for reference:

1696  /**
1697   * Display the language attributes for the html tag.
1698   *
1699 * Builds up a set of html attributes containing the text direction and language
1700   * information for the page.
1701   *
1702   * @since 2.1.0
1703   *
1704   * @param string $doctype The type of html document (xhtml|html).
1705   */
1706  function language_attributes($doctype = 'html') {
1707      $attributes = array();
1708      $output = '';
1709
1710      if ( $dir = get_bloginfo('text_direction') )
1711          $attributes[] = "dir=\"$dir\"";
1712
1713      if ( $lang = get_bloginfo('language') ) {
1714 if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
1715              $attributes[] = "lang=\"$lang\"";
1716
1717 if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
1718              $attributes[] = "xml:lang=\"$lang\"";
1719      }
1720
1721      $output = implode(' ', $attributes);
1722      $output = apply_filters('language_attributes', $output);
1723      echo $output;
1724  }

--
regards
takeshin

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to