So it's been a day and a half on this. Really need some help!
I cannot get $this->getChildHtml() to pull in my template. I have tried heaps but will outline the main things. First, my code:
app/design/frontend/.../template/pvtl/shiptwo/shiptwo-product-view.phtml
<p> This is the block you are looking for. </p> app/design/frontend/.../layout/pvtl_shiptwo.xml
<?xml version="1.0" ?> <layout> <catalog_product_view> <reference name="product.info"> <block type="pvtl_shiptwo/shiptwoView" name="view.shiptwo" as="shiptwoProductView" template="pvtl/shiptwo/shiptwo-product-view.phtml"/> </reference> </catalog_product_view> </layout> app/design/frontend/.../template/catalog/product/view.phtml
... <div class="product-view"> <div class="product-essential"> <?php echo $this->getBlockHtml('formkey') ?> <div class="no-display"> <input type="hidden" name="product" value="<?php echo $_product->getId() ?>"/> <input type="hidden" name="related_product" id="related-products-field" value=""/> </div> <div class="product-img-box"> <div class="product-name"> <h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1> </div> <?php echo $this->getChildHtml('media') ?> </div> <div class="product-shop"> <form action="<?php echo $this->getSubmitUrl($_product, array('_secure' => $this->_isSecure())) ?>" method="post" id="product_addtocart_form"<?php if ($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>> <div class="product-name"> <span class="h1"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></span> </div> <!-- Below should print template contents but doesn't --> <div class="shiptwo_product_view"> <?php echo $this->getChildHtml('shiptwoProductView'); ?> </div> ... I know the block is being loaded as the name is printed when I use
<?php echo "<pre>", print_r($this->getSortedChildren(), 1), "</pre>"; ?> I also tried the following:
<?php echo "<pre>", print_r($this->getChild('shiptwoProductView')->getTemplate(), 1), "</pre>"; ?> This returns the correct template path. I have checked this path tens of times. It is correct.
To make sure the block was actually working I created a method inside Pvtl_Shiptwo_Block_ShiptwoView:
public function showText() { return 'Working!'; } and called
<?php echo "<pre>", print_r($this->getChild('shiptwoProductView')->showText(), 1), "</pre>"; ?> This returned the correct output.
I am completely stuck on this! Somebody please help!!
Edit By request, here is my config.xml
<?xml version="1.0" ?> <config> <modules> <Pvtl_Shiptwo> <version>0.1</version> </Pvtl_Shiptwo> </modules> <global> <blocks> <pvtl_shiptwo> <class>Pvtl_Shiptwo_Block</class> </pvtl_shiptwo> </blocks> </global> <frontend> <routers> <pvtl_shiptwo> <use>standard</use> <args> <module>Pvtl_Shiptwo</module> <frontName>Shiptwo</frontName> </args> </pvtl_shiptwo> </routers> <layout> <updates> <pvtl_shiptwo> <file>pvtl_shiptwo.xml</file> </pvtl_shiptwo> </updates> </layout> </frontend> </config> Edit
Screenshot of folder structure
