Actions

Difference between revisions of "Objects, methods and properties available from your template"

From Joomla! Documentation

m (updated to 3.1)
m (update)
Line 55: Line 55:
 
[title] => Home  
 
[title] => Home  
 
[description] => Joomla 3 demo  
 
[description] => Joomla 3 demo  
[link] => [base] => http://j3demo.org/  
+
[link] => [base] => http://j3demo/  
 
[language] => en-gb  
 
[language] => en-gb  
 
[direction] => ltr  
 
[direction] => ltr  

Revision as of 07:56, 23 June 2013

According to <?php print_r($this); ?> in Joomla! 3.1, the object $this within the index.php file of the Protostar template looks like:

JDocumentHTML Object 
(
         [_links] => Array 
                (
                         [http://j3demo/?view=featured] => Array
                                 (
                                        [relation] => canonical
                                        [relType] => rel 
                                        [attribs] => Array 
                                                (
                                                 )
                                 )
                         [/index.php?format=feed&type=rss] => Array 
                                (
                                        [relation] => alternate 
                                        [relType] => rel 
                                        [attribs] => Array 
                                                ( 
                                                        [type] => application/rss+xml 
                                                        [title] => RSS 2.0 )
                                                 )
                                         [/index.php?format=feed&type=atom] => Array 
                                                ( 
                                                        [relation] => alternate 
                                                        [relType] => rel [attribs] => Array 
                                                                ( 
                                                                        [type] => application/atom+xml 
                                                                        [title] => Atom 1.0
                                                                 ) 
                                                 ) 
        [_custom] => Array 
                (
                 ) 
        [template] => protostar 
        [baseurl] => 
        [params] => JRegistry Object 
                ( 
                        [data:protected] => stdClass Object 
                                ( 
                                        [templateColor] => 
                                        [logoFile] => 
                                        [googleFont] => 1 
                                        [googleFontName] => Open+Sans 
                                        [fluidContainer] => 0 ) 
                                ) 
        [_file] => /home/j3demo/public_html/templates/protostar/index.php 
        [_template:protected] => 
        [_template_tags:protected] => Array 
                ( 
                ) 
        [_caching:protected] => 
        [_html5:JDocumentHTML:private] => 
        [title] => Home 
        [description] => Joomla 3 demo 
        [link] => [base] => http://j3demo/ 
        [language] => en-gb 
        [direction] => ltr 
        [_generator] => Joomla! - Open Source Content Management 
        [_mdate] => 
        [_tab] => 
        [_lineEnd] => 
        [_charset] => utf-8 
        [_mime] => text/html 
        [_namespace] => 
        [_profile] => 
        [_scripts] => Array 
                ( 
                        [/media/system/js/mootools-core.js] => Array 
                                ( 
                                        [mime] => text/javascript 
                                        [defer] => [async] => 
                                ) 
                        [/media/system/js/core.js] => Array 
                                ( 
                                        [mime] => text/javascript 
                                        [defer] => 
                                        [async] => 
                                )       
                        [/media/system/js/caption.js] => Array 
                                ( 
                                        [mime] => text/javascript 
                                        [defer] => 
                                        [async] => 
                                ) 
                        [/media/jui/js/jquery.min.js] => Array 
                                ( 
                                        [mime] => text/javascript 
                                        [defer] => 
                                        [async] => 
                                ) 
                        [/media/jui/js/jquery-noconflict.js] => Array 
                                ( 
                                        [mime] => text/javascript 
                                        [defer] => 
                                        [async] => 
                                ) 
                        [/media/jui/js/bootstrap.min.js] => Array 
                                ( 
                                        [mime] => text/javascript 
                                        [defer] => 
                                        [async] => 
                                ) 
                ) 
        [_script] => Array 
                ( 
                        [text/javascript] => window.addEvent('load', function() { 
                                new JCaption('img.caption'); 
                        }); ) 
        [_styleSheets] => Array 
                ( 
                        [templates/protostar/css/template.css] => Array 
                                ( 
                                        [mime] => text/css 
                                        [media] => 
                                        [attribs] => Array 
                                                ( 
                                                ) 
                                ) 
                ) 
        [_style] => Array 
                ( 
                ) 
        [_metaTags] => Array 
                ( 
                        [http-equiv] => Array 
                                ( 
                                        [content-type] => text/html; charset=utf-8 
                                ) 
                        [standard] => Array 
                                ( 
                                        [keywords] => 
                                        [rights] => 
                                ) 
                ) 
        [_engine] => 
        [_type] => html 
        [_errors:protected] => Array
                        (
                        )
)


Example of using objects

<link rel="stylesheet" href="<?=$this->baseurl ?>/templates/<?=$this->template ?>/css/template_css.css" type="text/css"/>