Creating a helper is quite easy, go on your /etc module directory and edit your config.xml file
ex : app/code/local/Adin/Epub/etc/config.xml
Add a
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <? xml version = "1.0" ?> < config > < modules > < Adin_Epub > < version >1.0.0</ version > </ Adin_Epub > </ modules > < global > < helpers > < epub > < class >Adin_Epub_Helper</ class > </ epub > </ helpers > </ global > </ config > |
Then creates the Helper folder on your module directory and create a data class :
app/code/local/Adin/Epub/Helper/Data.php
1 2 3 4 5 6 7 8 9 | <?php class Adin_Epub_Helper_Data extends Mage_Core_Helper_Abstract { //fonction de test public function getTest() { return "Ceci est un test de helper" ; } } |
If you create a new module, don’t forget to activate it, for that, in app/etc/modules directory, create or append a xml file and add your new module, for example :
1 2 3 4 5 6 7 8 9 | <? xml version = "1.0" ?> < config > < modules > < Adin_Epub > < active >true</ active > < codePool >local</ codePool > </ Adin_Epub > </ modules > </ config > |
Now, for using your new helper, just instanciate it and call the function :
1 2 | $helper = Mage::helper( 'epub' ); echo $helper ->getTest(); |