Difference between revisions of "Themes and XHTML"

From GeeklogWiki
Jump to: navigation, search
(Themes and XHTML)
(No difference)

Revision as of 17:13, 24 January 2010

Since version 1.5.0, Geeklog supports XHTML compliant themes. This means that Geeklog will automatically create XHTML compliant tags when required.

Switching to XHTML

Whether Geeklog will switch to XHTML compliant mode or not depends on the definition of a XHTML variable in the PHP code. This variable can either be defined by the theme (in the theme's functions.php file) or by selecting an XHTML DOCTYPE from the Configuation (since Geeklog 1.6.0):

Configuration > Geeklog > Theme > Theme > DOCTYPE Declaration

Selecting an XHTML DOCTYPE will automatically set the XHTML properly (any definition made by the theme still takes preference, though, so make sure the two don't conflict).

XHTML Constant and Template Variable

For an XHTML compliant theme, the XHTML constant should be defined like so:

define('XHTML', ' /');

Otherwise, the constant will be defined as an empty string:

define('XHTML', '');

The definition of the XHTML constant will also be available as a {xhtml} template variable in all template files used by Geeklog. This way, it is possible to create themes that will work both as XHTML and "plain" HTML by using the template variable for tags that have to be closed in XHTML, e.g.

<br{xhtml}>
<input type="submit" name="test"{xhtml}>
<img src="image.png" alt=""{xhtml}>

Other Template Variables

Themes that are written to be both valid HTML and XHTML (as described above) should use the {doctype} variable as the first line in header.thtml instead of hard-coding the DOCTYPE.

In XHTML mode, Geeklog will also provide a {xmlns} variable that will contain the xmlns attribute for the html element.

Putting it all together, the first 3 lines of your theme's header.thtml should look like this:

{doctype}
<html{lang_attribute}{xmlns}>
<head>

The {lang_attribute} will set a lang attribute in multi-language setups.