twitter
    Find out what I'm doing, Follow Me :)
Powered By Blogger

Wednesday, February 17, 2010

FAST FIXES FOR YOUR JOOMLA PROBLEMS

I get a lot of emails asking how to fix a particular problem in Joomla. Problems can arise for all sorts of reasons and are often caused by some incompatibility with your host or an extension. The following suggestions are very basic but I know many people are giving up too soon, so if you run into trouble, I hope you'll find this helpful:

If you receive an error message, copy the error and Google it. You may find a page where others are describing the same problem and hopefully a solution.
Search the Joomla forums and if there are no other relevant posts, start your own. It is helpful to describe your problem in as much detail as practical, including any errors you receive. Just be aware that this is a public forum and so it is a very bad idea to include private information such as passwords. If you are polite, you will most likely receive a friendly response.
If the problem relates to an extension, contact the extension developer directly. Many have a support page or forum on their site.
If time is against you, or you can't find an answer, consider paying an expert to fix the problem. You can try freelance sites such as Joomlancers, ODesk, Elance or Guru
If something is wrong but you are not receiving an error message, you might like to try bumping up the level of error reporting. In Administrator, go to Global Configuration - Server - Error Reporting - Maximum and remember to Save.

Friday, February 12, 2010

Magento: How to get all active payment modules

This code bellow will get you all active Magento payment modules. This example below return an array which you can use to create drop down menu or something else in Magento’s front-end or admin sections.

class Inchoo_Vendor_Model_Activpayment
{

public function getActivPaymentMethods()
{
$payments = Mage::getSingleton('payment/config')->getActiveMethods();

$methods = array(array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('--Please Select--')));

foreach ($payments as $paymentCode=>$paymentModel) {
$paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
$methods[$paymentCode] = array(
'label' => $paymentTitle,
'value' => $paymentCode,
);
}

return $methods;

}

}

Thursday, February 11, 2010

How to override Magento admin view (template) files, quick and dirty way

Suppose you are working on a extension that needs to either change some stuff or implement new stuff in the one of the Magento admin areas. For example, imagine a “Images” tab on the product edit section. If you were in a position where you need to do certain modifications on “Images” tab then you would most likely need to modify the app/design/adminhtml/default/default/template/catalog/product/helper/gallery.phtml file to do so. One of Inchoo coworkers and a good friend of mine, Ivan Weiler, made a Magento Admin theme module that enables you to achieve similar functionality for admin template files as you have for frontend template files.

However, sometimes you wont wish your extensions depend on the additional module for certain functionality. Stuff like “overriding” the admin view files can easily be achieved with just a few minor modifications of extended class.

Content of my app\code\community\MyCompany\MyModule\Block\Adminhtml\Catalog\Product\Helper\Form\Gallery\Content.php file.


class MyCompany_MyModule_Block_Adminhtml_Catalog_Product_Helper_Form_Gallery_Content extends Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content
{
/**
* This method has been overridden merely for the purpose of setting up a new view file
* to be used in place of the default theme folder.
*
* @see app/code/core/Mage/Core/Block/Mage_Core_Block_Template#fetchView($fileName)
*/
public function fetchView($fileName)
{
extract ($this->_viewVars);
$do = $this->getDirectOutput();

if (!$do) { ob_start(); }

include getcwd().'/app/code/community/MyCompany/MyModule/blocks/Adminhtml/catalog/product/helper/gallery.phtml';

if (!$do) {$html = ob_get_clean(); }
else { $html = ''; }

return $html;
}
}
Which goes inline with the config.xml file entry like:

...



MyCompany_MyModule_Block_Adminhtml_Catalog_Product_Helper_Form_Gallery_Content



...
In the example below, I am pointing the block to look for my view file within my module folder, and not within some Magento design folder. Basically my gallery.phtml is the same as the original Magento adminhtml view file for the same purpose, but now I can go in and implement my additional stuff in it.

Approach like this can have its advantage in terms of keeping all the required overridden design files in your own module directory.

For those who need it… cheers.