API15

JTemplate/getInstance

From Joomla! Documentation

< API15:JTemplate
Revision as of 17:23, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Returns a reference to a global Template object, only creating it if it doesn't already exist. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Returns a reference to a global Template object, only creating it if it doesn't already exist.

[Edit Descripton]

Template:Description:JTemplate/getInstance

Syntax[edit]

& getInstance($type= 'html')
Parameter Name Default Value Description
$type 'html' $type (either html or tex)

Returns[edit]

jtemplate A template object

Defined in[edit]

libraries/joomla/template/template.php

Importing[edit]

jimport( 'joomla.template.template' );

Source Body[edit]

function &getInstance( $type = 'html' )
{
        static $instances;

        if (!isset( $instances )) {
                $instances = array();
        }

        $signature = serialize(array($type));

        if (empty($instances[$signature])) {
                $instances[$signature] = new JTemplate($type);
        }

        return $instances[$signature];
}

[Edit See Also] Template:SeeAlso:JTemplate/getInstance

Examples[edit]

<CodeExamplesForm />