{"id":1588,"date":"2012-07-19T13:13:03","date_gmt":"2012-07-19T13:13:03","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2012\/07\/19\/this\/"},"modified":"2021-08-16T23:39:15","modified_gmt":"2021-08-17T03:39:15","slug":"this","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/","title":{"rendered":"Joomla 2.5 Templates &#8211; $this->"},"content":{"rendered":"<p>We are continuing to review Joomla 2.5&#8217;s Beez2 template code, and we next come accross the following code:<\/p>\n<pre class=\"code_block\">&lt;html xmlns=\"https:\/\/www.w3.org\/1999\/xhtml\" xml:lang=\"&lt;?php echo <strong><span style=\"color: #ff0000;\">$this-&gt;<\/span><\/strong>language; ?&gt;\" lang=\"&lt;?php echo <span style=\"color: #ff0000;\"><strong>$this-&gt;<\/strong><\/span>language; ?&gt;\" dir=\"&lt;?php echo <span style=\"color: #ff0000;\"><strong>$this-&gt;<\/strong><\/span>direction; ?&gt;\" &gt;<\/pre>\n<p>In our review thus far, we have alread seen instances of <strong>$this-&gt;<\/strong>, for example:<\/p>\n<ul>\n<li><a href=\"\/support\/edu\/joomla\/joomla-2-5\/showrightcolumn\/\">$showRightColumn<\/a><\/li>\n<li><a href=\"\/support\/edu\/joomla\/joomla-2-5\/this-countmodules\/\">$this-&gt;countModules<\/a><\/li>\n<li><a href=\"\/support\/edu\/joomla\/joomla-2-5\/this-params-get\/\">$this-&gt;params-&gt;get<\/a><\/li>\n<\/ul>\n<h2>What is $this-&gt; ?<\/h2>\n<p>Technically speaking, in PHP $this refers to the current object. PHP will set the contents of $this when you are inside a function of an object.<\/p>\n<p>If we update our template&#8217;s code as follows, we can see more information about $this:<\/p>\n<pre class=\"code_block\"><span style=\"color: #ff0000;\"><strong>&lt;? echo \"&lt;pre&gt;\"; print_r($this); echo \"&lt;\/pre&gt;\"; die(); ?&gt;<\/strong><\/span> &lt;html xmlns=\"https:\/\/www.w3.org\/1999\/xhtml\" xml:lang=\"&lt;?php echo $this-&gt;language; ?&gt;\" lang=\"&lt;?php echo $this-&gt;language; ?&gt;\" dir=\"&lt;?php echo $this-&gt;direction; ?&gt;\" &gt;<\/pre>\n<p>The output above is quite long, and below we&#8217;ve included the first few lines only:<\/p>\n<pre class=\"code_block\">JDocumentHTML Object\n(\n    [_links] =&gt; Array\n        (\n            [\/joomla25\/index.php?format=feed&amp;type=rss] =&gt; Array\n                (\n                    [relation] =&gt; alternate\n                    [relType] =&gt; rel\n                    [attribs] =&gt; Array\n                        (\n                            [type] =&gt; application\/rss+xml\n                            [title] =&gt; RSS 2.0\n                        )<\/pre>\n<p>Based upon the first line, $this appears to be referring to the <strong>JDocumentHTML Object<\/strong>, which we touched based on in a <a href=\"\/support\/edu\/joomla\/joomla-2-5\/jfactory-get-document\/\">previous article<\/a>.<\/p>\n<h2>When is $this-&gt; used in the Beez2 template?<\/h2>\n<p>When scanning the index.php file of the Beez2 template, there are several uses of <strong>$this<\/strong>:<\/p>\n<ul>\n<li><a href=\"\/support\/edu\/joomla\/joomla-2-5\/this-countmodules\/\">$this-&gt;countModules()<\/a><\/li>\n<li><a href=\"\/support\/edu\/joomla\/joomla-2-5\/this-params-get\/\">$this-&gt;params-&gt;get()<\/a><\/li>\n<li><a href=\"\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/\">$this-&gt;baseurl<\/a><\/li>\n<li><a href=\"\/support\/edu\/joomla\/joomla-2-5\/this-template\/\">$this-&gt;template<\/a><\/li>\n<li><a href=\"\/support\/edu\/joomla\/joomla-2-5\/this-language\/\">$this-&gt;language<\/a><\/li>\n<li><a href=\"\/support\/edu\/joomla\/joomla-2-5\/this-direction\/\">$this-&gt;direction<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>We are continuing to review Joomla 2.5&#8217;s Beez2 template code, and we next come accross the following code: &lt;html xmlns=&#8221;https:\/\/www.w3.org\/1999\/xhtml&#8221; xml:lang=&#8221;&lt;?php echo $this-&gt;language; ?&gt;&#8221; lang=&#8221;&lt;?php echo $this-&gt;language; ?&gt;&#8221; dir=&#8221;&lt;?php echo $this-&gt;direction; ?&gt;&#8221; &gt; In our review thus far, we have alread seen instances of $this-&gt;, for example: $showRightColumn $this-&gt;countModules $this-&gt;params-&gt;get What is $this-&gt; ? Technically<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/\"> Read More ><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4403,82],"tags":[2113],"class_list":["post-1588","post","type-post","status-publish","format-standard","hentry","category-joomla","category-joomla-2-5","tag-joomla-v2-5"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Joomla 2.5 Templates - $this-&gt; | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"The $this variable is used quite often in the Beez2 Joomla 2.5 template, and it references the JDocumentHTML Object.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Joomla 2.5 Templates - $this-&gt; | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"The $this variable is used quite often in the Beez2 Joomla 2.5 template, and it references the JDocumentHTML Object.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2012-07-19T13:13:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-17T03:39:15+00:00\" \/>\n<meta name=\"author\" content=\"Brad Markle\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brad Markle\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/\"},\"author\":{\"name\":\"Brad Markle\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf\"},\"headline\":\"Joomla 2.5 Templates &#8211; $this->\",\"datePublished\":\"2012-07-19T13:13:03+00:00\",\"dateModified\":\"2021-08-17T03:39:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/\"},\"wordCount\":176,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"keywords\":[\"Joomla v2.5\"],\"articleSection\":[\"Joomla\",\"Joomla 2.5\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/\",\"name\":\"Joomla 2.5 Templates - $this-> | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2012-07-19T13:13:03+00:00\",\"dateModified\":\"2021-08-17T03:39:15+00:00\",\"description\":\"The $this variable is used quite often in the Beez2 Joomla 2.5 template, and it references the JDocumentHTML Object.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Joomla 2.5 Templates &#8211; $this->\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf\",\"name\":\"Brad Markle\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/bradm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Joomla 2.5 Templates - $this-> | InMotion Hosting","description":"The $this variable is used quite often in the Beez2 Joomla 2.5 template, and it references the JDocumentHTML Object.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/","og_locale":"en_US","og_type":"article","og_title":"Joomla 2.5 Templates - $this-> | InMotion Hosting","og_description":"The $this variable is used quite often in the Beez2 Joomla 2.5 template, and it references the JDocumentHTML Object.","og_url":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2012-07-19T13:13:03+00:00","article_modified_time":"2021-08-17T03:39:15+00:00","author":"Brad Markle","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Brad Markle","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/"},"author":{"name":"Brad Markle","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf"},"headline":"Joomla 2.5 Templates &#8211; $this->","datePublished":"2012-07-19T13:13:03+00:00","dateModified":"2021-08-17T03:39:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/"},"wordCount":176,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"keywords":["Joomla v2.5"],"articleSection":["Joomla","Joomla 2.5"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/","url":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/","name":"Joomla 2.5 Templates - $this-> | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2012-07-19T13:13:03+00:00","dateModified":"2021-08-17T03:39:15+00:00","description":"The $this variable is used quite often in the Beez2 Joomla 2.5 template, and it references the JDocumentHTML Object.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"Joomla 2.5 Templates &#8211; $this->"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf","name":"Brad Markle","url":"https:\/\/www.inmotionhosting.com\/support\/author\/bradm\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/1588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=1588"}],"version-history":[{"count":3,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/1588\/revisions"}],"predecessor-version":[{"id":85805,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/1588\/revisions\/85805"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=1588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=1588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=1588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}