Joomla 2.5 Templates – $this->baseurl Brad MarkleUpdated on February 21, 2022 2 Minute Read 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 following code: $doc->addScript($this->baseurl.'/templates/'.$this->template.'/javascript/md_stylechanger.js', 'text/javascript', true); In this article, we will focus on $this->baseurl What is $this->baseurl? We can view the content of $this->baseurl by adjusting our PHP code as follows: $doc->addScript($this->baseurl.'/templates/'.$this->template.'/javascript/md_stylechanger.js', 'text/javascript', true); echo "<pre>" . $this->baseurl . "</pre>"; die(); The result of this code prints the following to the screen: /joomla25 When we installed Joomla 2.5, we installed it at https://domain.com/joomla25. $this->baseurl 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. Example usage of $this->baseurl If you didn’t want to hard code a link to your homepage (just in case you change the URL), you can use $this->baseurl to print it instead. In this tutorial, we’ll walk you through the steps for using $this->baseurl to set the logo in the Beez2 template to link to your homepage. To use $this->baseurl in a Joomla 2.5 Template: Use your favorite file editor and open for edit: templates/beez_20/index.php At line 118, replace the following line: <img src="<?php echo $this->baseurl ?>/<?php echo htmlspecialchars($logo); ?>" alt="<?php echo htmlspecialchars($templateparams->get('sitetitle'));?>" /> with… <a href="<? echo $this->baseurl; ?>"><img src="<?php echo $this->baseurl ?>/<?php echo htmlspecialchars($logo); ?>" alt="<?php echo htmlspecialchars($templateparams->get('sitetitle'));?>" /></a> What we did was put the Joomla site’s logo image within an <a></a> tag. Instead of typing the url as: <a href="https://domain.com"></a> … we used the following: <a href="<? echo $this->baseurl; ?>"></a> Save the file and visit your website to see the changes. It’s that easy! Anywhere within a Joomla 2.5 template, you can use $this->baseurl to print the URL to your Joomla site. Share this Article Related Articles Prevent New Account activation email sent to Joomla 2.5 Administrator Joomla 3.1 Error – Could not instantiate mail function How to Create a Slideshow (Carousel) in Joomla 4.0 using Bootstrap How to write a blog post in Joomla 3.1 How to Use the Free Mini Frontpage Extension for Joomla 4.0 How to Change a Joomla 2.5 User’s Email Address How to Configure Joomla 2.5 to Send Email Using SMTP How to Edit a Joomla 3 Template How to install Phoca Gallery for Joomla 2.5 Creating a Menu Item for your Joomla 3 Component