Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

magento Get Base Url , Skin Url , Media Url , Js Url , Store Url and Current Url for secure

I am newbie to the magento. I am developing a module. For that I have some css andjs files that I want to display links. I currently have the links like

<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('module_tryouts/css/jquery.fancybox-1.3.1.css');?>" media="all" />

<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('module_tryouts/css/jquery-ui-1.8.custom.css');?>" media="all" />

But after going through some of the links I came to know that the link should be secure so that the module can be integrated with mazebridge.

http://jagdeepbanga.com/blog/magento-get-base-url-skin-url-media-url-js-url-store-url-and-current-url.html

http://www.webdosh.net/2011/04/magento-get-skin-url-get-media-url-get.html

http://www.magentocommerce.com/boards/viewthread/7894/

http://www.yireo.com/tutorials/magebridge/integrations/1213-integrating-magebridge-with-other-magento-extensions

So can someone kindly tell me how to solve this issue? How to give a secure links to the files of js and css, images so that it can be integrated with mazebridge. Any help and suggestions will be really appreciated. Thanks

like image 498
NewUser Avatar asked Dec 15 '22 07:12

NewUser


1 Answers

Below URL Access list

Get URLs in CMS pages or static blocks

  1. Base URL:

    {{base url=''}}
    
  2. Store URL:

    {{store url='test.html'}}
    

    also only store URL

    {{store url=""}}
    
  3. Media URL:

    only get media URL

    {{media url=''}}
    

    if you get some folder path

    {{media url='imagefolder/imagename.jpg'}}
    
  4. Skin URL:

    {{skin url='images/imagename.jpg'}}
    

    only get skin URL

    {{skin url=''}}
    


Get URLs in PHP files (incl. templates/PHTML)

  1. Get Base Url in magento:

    $baseurl = Mage::getBaseUrl();
    

    Get Base Url without index.php

    Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); 
    
    // output: http://example.com/
    
  2. Current Url

    $currentUrl = Mage::helper('core/url')->getCurrentUrl();
    

    or

    $currentUrl = Mage::getUrl('*/*/*', array('_current' => true));
    

    or

    if (!in_array(Mage::app()->getFrontController()->getAction()->getFullActionName(), array('cms_index_noRoute', 'cms_index_defaultNoRoute'))) 
    {
        $currentUrl = Mage::helper('core/url')->getCurrentUrl();
    }
    
  3. Skin URL:

    $skinUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
    

    Unsecure Skin URL:

    $skinUrl = $this->getSkinUrl('images/imagename.jpg');
    

    Secure Skin URL:

    $this->getSkinUrl('images/imagename.gif', array('_secure'=>true));
    
  4. Media URL

    $mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
    

    or

    $mediaUrl = Mage::getBaseUrl('media');
    
  5. Get Js URL:

    $jsUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
    

    or

    $jsUrl = Mage::getBaseUrl('js');
    
  6. get store URL:

    $storeUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
    
  7. Get Home URL:

    $homeUrl= Mage::helper('core/url')->getHomeUrl();
    
  8. Get Directory paths

    Mage::getBaseDir('design') // Get design directory path
    Mage::getBaseDir('code')   // Gives code directory file path
    Mage::getBaseDir('lib')    // Gives lib directory file path
    Mage::getBaseDir('skin')   // Gives skin directory file path
    Mage::getBaseDir('var')    // Gives var directory file path
    Mage::getBaseDir('cache')  // Gives cache directory file path
    Mage::getBaseDir('log')    // Gives log directory file path
    
  9. Create module URL:

    Mage::getUrl('module/controller/action');
    
like image 112
Kailas Avatar answered Apr 26 '23 22:04

Kailas