Block fails on (live) server but works on localhost?

by Kennet Leth Sørensen   Last Updated September 17, 2018 22:09 PM

I've added a custom block to catalog/product/view.phtml using echo $this->getLayout()->createBlock('colorchart/colorchart')->setTemplate('colorchart/colorchart.phtml')->toHtml(); and it's working great on my localhost (Wamp) but I get this error when pushing to my live server: Fatal error: Uncaught Error: Call to a member function toHtml() on boolean in /var/www/..../template/catalog/product/view.phtml

I've also tried just using echo $this->getLayout()->createBlock('colorchart/colorchart')->toHtml(); in my view.phtml file and then the following in my block (app/code/local/MyName/ColorChart/Block/ColorChart.php):

 public function __construct()

Again, this works perfectly on my localhost but not on the live server? I run the same PHP & magento version on localhost and the server...?

I've mostly been working with Magento 2, so I'm a bit lost with Magento 1.9.3? I don't think I need a controller as I'm not targeting an URL or rendering a full page? Maybe I need to create a layout XML file, but I can't figure out where to put this for my custom block/module in Magento 1.9.3? Here is my code:


class MyName_ColorChart_Block_ColorChart extends Mage_Core_Block_Template
{/** MyName_ColorChart_Block_ColorChart constructor. */
public function __construct()
public function getColorProducts($id) {
   // several functions below here


<?xml version="1.0"?>


<?php $mainProduct = Mage::registry('current_product'); ?>
    <?php if ($mainProduct->getColorChart()) : ?>
        <?php $selectValues = $this->allNewFunction($mainProduct->getId()); ?>
        <div> .... a lot of HTML code and PHP logic .... </div>


<?php if ($_product->getShortDescription()):?>
    // code from magento here
<?php endif;?>

<div class="pro-left">
<!-- ------ I put my code here (Color Chart) ------ -->
    echo $this->getLayout()->createBlock('colorchart/colorchart')->toHtml();
<!-- ------ End of my code ------ -->
<div class="add_to_cart">
   <?php if (!$this->hasOptions()):?> // 
// ...snip...

Related Questions

Load products page inside phtml page Magento 2

Updated September 06, 2017 09:09 AM

how to add the block from other xml file

Updated June 10, 2015 22:04 PM

Add phtml to Customer Account Edit in Adminhtml

Updated April 27, 2018 07:09 AM

Magento custom block not showing on frontend

Updated May 22, 2018 11:09 AM