Hello I would like to modify the product view page, and inject php into it via my extension. I tried doing it via editing the transport block, but it can only add html files and not php files. I also tried appending an additional layout externally...to no avail.
if ($block instanceof Mage_Catalog_Block_Product_View)
{
$block = $observer->getLayout()->createBlock('demo\productrender.phtml');
$observer->getLayout()->getBlock('content')->append($block);
}
The code which i need to inject externally:
// Facebook
<a href="javascript:popWin('https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode($productUrl); ?>&t=<?php echo urlencode($productName); ?>', 'facebook', 'width=640,height=480,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes');"
title="<?php echo $this->__('Share on Facebook') ?>">Facebook</a>
<a href="javascript:myAjax()">Ajax</a>
<?php echo Mage::app()->getRequest()->getControllerName(); ?>
// return module name
<?php echo $this->getUrl('demo/Ajax/index') ?>
<script>
function myAjax() {
new Ajax.Request("<?php echo $this->getUrl('demo/Ajax/index') ?>", {
method: 'Post',
parameters: {
"productinfo":<?php echo $_product->getSku()?>,
"productprice":<?php echo $_product->getPrice()?>
},
onComplete: function (transport) {
alert(transport.responseText);
}
});
}
</script>