B-219 Sec-55 Noida, India

Magento Application some useful functions we used in development

Sometimes we need to check the current host name in magento. Here is the function that returns the hostname of server where the application is executing.

The following code is same as normal PHP $_SERVER[‘HTTP_HOST’]

<?php      echo Mage::app()->getFrontController()->getRequest()->getHttpHost();?>

 It returns if we runs on or in other cases it returns the domain name of the site.
 When we want to retrieve the Path of Base Directory in Magento. We can use the following function

 <?php echo Mage::getBaseDir();  //gives  physical path of the sites root directory ?>

(In my case it return e:wwwmagento )

Its returns the Physical path of the Application directory where magento application installed.
When we want to retrieve the relative path of the sites default skin folder. IT return the virtual path of the default skin folder. Many time we used in theme development

 <?php echo $this->getSkinURL(); ?>

 It returns the
Virtual path of the magneto application can be retrieved with the following function. Relative path of the Magento site

<?php echo Mage::getBaseURL();   ?>
<?php echo Mage::getURL();?>

(Visited 69 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.