Created
April 10, 2015 11:11
-
-
Save rattrap/1081b8316896c8e09fc4 to your computer and use it in GitHub Desktop.
Magento ifconfig block and dynamic assets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @category Package | |
* @package Namespace_Package | |
* @license http://opensource.org/licenses/MIT | |
* @author Leonard Mocanu <[email protected]> | |
*/ | |
class Namespace_Package_Helper_Data extends Mage_Core_Helper_Abstract { | |
/** | |
* Get link tag | |
* | |
* @return string | |
*/ | |
public function getCssUrl() { | |
return sprintf('<link rel="stylesheet" href="%s">', $this->_getConfig()->getCssUrl()); | |
} | |
/** | |
* Get script tag | |
* | |
* @return string | |
*/ | |
public function getJsUrl() { | |
return sprintf('<script type="text/javascript" src="%s"></script>', $this->_getConfig()->getJsUrl()); | |
} | |
/** | |
* Get the config model | |
* | |
* @return Namespace_Package_Model_Config | |
*/ | |
protected function _getConfig() { | |
return Mage::getModel('namespace_package/config'); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<!-- | |
@category Package | |
@package Namespace_Package | |
@license http://opensource.org/licenses/MIT | |
@author Leonard Mocanu <[email protected]> | |
--> | |
<layout version="0.1.0"> | |
<!-- HEAD --> | |
<catalog_product_view> | |
<reference name="head"> | |
<block type="core/text" name="namespace.package.css"> | |
<action method="setText" ifconfig="namespace_package/enabled_some_block"> | |
<url helper="namespace_package/getCssUrl"></url> | |
</action> | |
</block> | |
<block type="core/text" name="namespace.package.js"> | |
<action method="setText" ifconfig="namespace_package/enabled_some_block"> | |
<url helper="namespace_package/getJsUrl"></url> | |
</action> | |
</block> | |
</reference> | |
</catalog_product_view> | |
<!-- //HEAD// --> | |
<!-- SOME BLOCK --> | |
<catalog_product_view> | |
<reference name="product.info.addtocart"> | |
<block type="page/html_wrapper" name="product.info.addtocart.some_block.wrapper" translate="label"> | |
<label>Some Block Wrapper</label> | |
<block type="namespace_package/product_view_some_block" name="product.info.addtocart.some_block" as="some_block"> | |
<action method="setTemplate" ifconfig="namespace_package/enabled_some_block"> | |
<template>namespace_package/some_block.phtml</template> | |
</action> | |
</block> | |
</block> | |
</reference> | |
</catalog_product_view> | |
<!-- //SOME BLOCK// --> | |
</layout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Couldn't add CSS and JS with addItem 'cause they're external.