Call a PHP script from Magento

I recently had some difficulty calling a simple PHP script from within the Magento eCommerce Platform. Although the following example focuses on calling a VoltRank PHP script, you can replace the code within VRank.phtml with your own PHP script.

VoltRank PHP Script Installation in Magento

Create a new template file to contain the PHP. The file should reside within the ‘template’ directory. I have put the file within the “catalog/category” subdirectory:

VoltRank VRank.phtml in template Directory

VoltRank VRank.phtml in template Directory

Copy and paste your PHP code into the .phtml file:

VoltRank PHP Code

VoltRank PHP Code

Call PHP from Magento Static Block

Using the Magento GUI interface, navigate to CMS->Static Blocks and select the block to be edited. In this case, I am editing the Footer Left block. Create the highlighted code to call the template code.

Magento Call Voltrank to PHP code

Magento Call Voltrank to PHP code

{{block type= 'catalog/navigation' name='catalog.category' template='catalog/category/VRank.phtml'}}

Call VoltRank PHP Script from Magento – Troubleshooting

If it looks like the PHP script is not being called, then take steps to debug by turning on display of errors in index.php. Uncomment this line:

#ini_set('display_errors', 1);

Any errors should then display on the page if there is a problem with the PHP. Otherwise, your Magento eCommerce CMS should be successfully calling your VoltRank PHP code!

Special Offer

In addition to using VoltRank to increase traffic to your website and push it higher in the search engines, you may want to build some links to your website using Linxboss and at the same time get 125-150 FREE LINKS to your website. See our Linxboss Review for further information.