Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento CMS Page - include external PHP script

Tags:

php

magento

I want to include external PHP script in Magento CMS Pages

e.g.

**http://myhost/magento/custom/script.php**

<?php echo "hello"; ?>

Result on Magento Page should be: "hello"

What would be the simplest way to do this?

like image 337
enloz Avatar asked Sep 16 '26 04:09

enloz


2 Answers

The best way would probably be via the Layout Update XML section (on the design tab). You can either create a new block for your template php file, or use Mage_Core_Block_Template. Add this:

<reference name="content">
    <block type="core/template" name="my_template" template="pat/to/your/template" after="cms_page" />
</reference>
like image 84
Peter O'Callaghan Avatar answered Sep 17 '26 19:09

Peter O'Callaghan


OR
You can use curly braces syntax in order to include .phtml file where you can write your PHP code as:

{{block type="core/template" name="my-template" template="path/to/your/template.phtml"}}

Thanks

like image 28
MagePsycho Avatar answered Sep 17 '26 17:09

MagePsycho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!