{"id":1207,"date":"2012-03-08T20:28:33","date_gmt":"2012-03-08T20:28:33","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2012\/03\/08\/this-baseurl\/"},"modified":"2022-02-21T14:44:27","modified_gmt":"2022-02-21T19:44:27","slug":"this-baseurl","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/","title":{"rendered":"Joomla 2.5 Templates &#8211; $this->baseurl"},"content":{"rendered":"\n<p class=\"alert alert-warning\">Joomla 2.5 has reached its end of life as for 12\/31\/2014. Please be advised this may be a security risk to your website. You can view more information about the end of life <a href=\"https:\/\/docs.joomla.org\/Joomla!_CMS_versions\">here<\/a>.<\/p>\n\n\n\n<p>In our quest to review all the PHP code in the index.php file of the Beez2 template, we come to the following code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$doc-&gt;addScript($this-&gt;baseurl.'\/templates\/'.$this-&gt;template.'\/javascript\/md_stylechanger.js', 'text\/javascript', true);<\/code><\/pre>\n\n\n\n<p>In this article, we will focus on <strong>$this-&gt;baseurl<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is $this-&gt;baseurl?<\/h2>\n\n\n\n<p>We can view the content of <code>$this-&gt;baseurl<\/code> by adjusting our PHP code as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$doc-&gt;addScript($this-&gt;baseurl.'\/templates\/'.$this-&gt;template.'\/javascript\/md_stylechanger.js', 'text\/javascript', true);\necho \"&lt;pre&gt;\" . $this-&gt;baseurl . \"&lt;\/pre&gt;\"; die();<\/code><\/pre>\n\n\n\n<p>The result of this code prints the following to the screen:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/joomla25<\/code><\/pre>\n\n\n\n<p>When we installed Joomla 2.5, we installed it at https:\/\/domain.com\/joomla25. <code>$this-&gt;baseurl<\/code> contains the location within your domain that Joomla is installed at. Knowing the path to Joomla is useful because you can use it to reference other files and build the URLs to your javascript and css files.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example usage of $this-&gt;baseurl<\/h2>\n\n\n\n<p>If you didn&#8217;t want to hard code a link to your homepage (just in case you change the URL), you can use $this-&gt;baseurl to print it instead. In this tutorial, we&#8217;ll walk you through the steps for using $this-&gt;baseurl to set the logo in the Beez2 template to link to your homepage.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>To use $this-&gt;baseurl in a Joomla 2.5 Template:<\/strong><\/h3>\n\n\n\n<ol class=\"article_list wp-block-list\"><li>Use your favorite file editor and open for edit:\n<p class=\"code_block\">templates\/beez_20\/index.php<\/p>\n<\/li><li> At line 118, replace the following line:\n<pre class=\"code_block\" style=\"white-space: nowrap; max-width: 500px;\">&lt;img src=\"&lt;?php echo $this-&gt;baseurl ?&gt;\/&lt;?php echo htmlspecialchars($logo); ?&gt;\"&nbsp; alt=\"&lt;?php echo htmlspecialchars($templateparams-&gt;get('sitetitle'));?&gt;\" \/&gt;<\/pre>\n<p> with&#8230; <\/p>\n<pre class=\"code_block\" style=\"white-space: nowrap; max-width: 500px;\">&lt;a href=\"&lt;? echo $this-&gt;baseurl; ?&gt;\"&gt;&lt;img src=\"&lt;?php echo $this-&gt;baseurl ?&gt;\/&lt;?php echo htmlspecialchars($logo); ?&gt;\"&nbsp; alt=\"&lt;?php echo htmlspecialchars($templateparams-&gt;get('sitetitle'));?&gt;\" \/&gt;&lt;\/a&gt;<\/pre>\n<p>What we did was put the Joomla site&#8217;s logo image within an &lt;a&gt;&lt;\/a&gt;  tag. Instead of typing the url as:<\/p>\n<code>&lt;a href=\"https:\/\/domain.com\"&gt;&lt;\/a&gt;<\/code>\n<p> &#8230; we used the following: <\/p>\n<code>&lt;a href=\"&lt;? echo $this-&gt;baseurl; ?&gt;\"&gt;&lt;\/a&gt;<\/code>\n<\/li><li>Save the file and visit your website to see the changes.<\/li><\/ol>\n\n\n\n<p>It&#8217;s that easy! Anywhere within a Joomla 2.5 template, you can use <code>$this-&gt;baseurl<\/code> to print the URL to your Joomla site.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Joomla 2.5 has reached its end of life as for 12\/31\/2014. Please be advised this may be a security risk to your website. You can view more information about the end of life here. In our quest to review all the PHP code in the index.php file of the Beez2 template, we come to the<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/\"> 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-1207","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;baseurl | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"In this tutorial, we&#039;ll show you how to use the $this-baseurl variable within a Joomla template to reference your site&#039;s URL.\" \/>\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-baseurl\/\" \/>\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;baseurl | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we&#039;ll show you how to use the $this-baseurl variable within a Joomla template to reference your site&#039;s URL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/\" \/>\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-03-08T20:28:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-21T19:44:27+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=\"2 minutes\" \/>\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-baseurl\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/\"},\"author\":{\"name\":\"Brad Markle\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf\"},\"headline\":\"Joomla 2.5 Templates &#8211; $this->baseurl\",\"datePublished\":\"2012-03-08T20:28:33+00:00\",\"dateModified\":\"2022-02-21T19:44:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/\"},\"wordCount\":303,\"commentCount\":6,\"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-baseurl\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/\",\"name\":\"Joomla 2.5 Templates - $this->baseurl | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2012-03-08T20:28:33+00:00\",\"dateModified\":\"2022-02-21T19:44:27+00:00\",\"description\":\"In this tutorial, we'll show you how to use the $this-baseurl variable within a Joomla template to reference your site's URL.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/#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->baseurl\"}]},{\"@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->baseurl | InMotion Hosting","description":"In this tutorial, we'll show you how to use the $this-baseurl variable within a Joomla template to reference your site's URL.","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-baseurl\/","og_locale":"en_US","og_type":"article","og_title":"Joomla 2.5 Templates - $this->baseurl | InMotion Hosting","og_description":"In this tutorial, we'll show you how to use the $this-baseurl variable within a Joomla template to reference your site's URL.","og_url":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2012-03-08T20:28:33+00:00","article_modified_time":"2022-02-21T19:44:27+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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/"},"author":{"name":"Brad Markle","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf"},"headline":"Joomla 2.5 Templates &#8211; $this->baseurl","datePublished":"2012-03-08T20:28:33+00:00","dateModified":"2022-02-21T19:44:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/"},"wordCount":303,"commentCount":6,"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-baseurl\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/","url":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/","name":"Joomla 2.5 Templates - $this->baseurl | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2012-03-08T20:28:33+00:00","dateModified":"2022-02-21T19:44:27+00:00","description":"In this tutorial, we'll show you how to use the $this-baseurl variable within a Joomla template to reference your site's URL.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-2-5\/this-baseurl\/#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->baseurl"}]},{"@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\/1207","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=1207"}],"version-history":[{"count":7,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/1207\/revisions"}],"predecessor-version":[{"id":94302,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/1207\/revisions\/94302"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=1207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=1207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=1207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}