Php Magento在自定义页面上查看表单

Php Magento在自定义页面上查看表单,php,magento,Php,Magento,我已经使用自定义页面的xml布局将评论表单放到了自定义页面上。自定义页面位于“我的帐户”部分,显示客户订购的所有产品 <reference name="content"> <block type="review/form" name="product.info.review_form" as="review_form" template="review/form.phtml"/> </reference> 但它不起作用,我将遇到的另一个问题是

我已经使用自定义页面的xml布局将评论表单放到了自定义页面上。自定义页面位于“我的帐户”部分,显示客户订购的所有产品

<reference name="content">
        <block type="review/form" name="product.info.review_form" as="review_form" template="review/form.phtml"/>
</reference>
但它不起作用,我将遇到的另一个问题是将产品ID插入表单操作。我走错方向了吗

更新完整代码:

<?php
if (Mage::getSingleton('customer/session')->isLoggedIn()) {

/* Get the customer data */
$customer       = Mage::getSingleton('customer/session')->getCustomer();
/* Get the customer's email address */
$customer_email = $customer->getEmail();

}

$collection = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_email', array(
'like' => $customer_email
));



$uniuqProductSkus = array();

foreach ($collection as $order) { 

    $order_id = $order->getId(); 
    $order = Mage::getModel("sales/order")->load($order_id); 
    $ordered_items = $order->getAllItems(); 
        foreach ($ordered_items as $item) 
        { 
        if (in_array($item->getProduct()->getSku(), $uniuqProductSkus)) { 
        continue; 
        } else { 
            array_push($uniuqProductSkus, $item->getProduct()->getSku()); 

            $_product                 = Mage::getModel('catalog/product')->load($item->getProductId());
            $product_small_image_path = Mage::helper('catalog/image')->init($_product, 'small_image')->resize(200);
            $product_thumbnail_path   = Mage::helper('catalog/image')->init($_product, 'small_image')->resize(150);
            $summaryData              = Mage::getModel('review/review_summary')->load($item->getProductId());


            echo "<li>";

            echo "<div class='previous-name'><p><a  style='color:black; font-weight:bold; font-size:14px;' href='" . $_product->getProductUrl() . "'>";
            echo $item->getName() . "</a></p></div>";

            echo "<div class='previous-image'><a href='" . $_product->getProductUrl() . "'>";
            echo "<img src='" . $product_small_image_path . "' />";
            echo "</a></div>";

            echo "<div class='previous-rating'>";
            echo "<p><a  style='color:black; font-weight:bold; font-size:14px;' href='" . $_product->getProductUrl() . "#product_tabs_review_tabbed'>Review this beer now</a></p>";

            echo $summaryData->getRatingSummary() . '% Would buy again <br/>';

            echo "<div class='rating-box' style='float:left;'>";
            echo "<div class='rating' style='width:" . $summaryData->getRatingSummary() . "%'></div></div>";
            echo "<div class='previous-clear'></div></div>";



            $productsreviews = Mage::getModel('review/review')->getProductCollection()->addCustomerFilter(Mage::getSingleton('customer/session')->getCustomerId())->setDateOrder();
            foreach ($productsreviews as $productsreview)
            {
                $product = Mage::getModel('catalog/product')->load($productsreview->getData('entity_pk_value')); 
            }

            echo $product->getRating();

            ?>

            <script type="text/javascript">
                    function toggle_visibility(id) {
                       var e = document.getElementById(id);
                       if(e.style.display == 'block')
                          e.style.display = 'none';
                       else
                          e.style.display = 'block';
                    }
                </script>



            <?php

            echo '<a href="#" onclick="toggle_visibility(\'ajaxpro-notice-form' . $_product->getId().'\');" >Review Now</a>';

            echo "<div id='ajaxpro-notice-form" . $_product->getId()."' class='ajaxpro-form' style='display:none'>";
            echo '<a href="#" onclick="toggle_visibility(\'ajaxpro-notice-form' . $_product->getId().'\');" class="btn-close ajaxpro-button" title="Remove This Item">Remove This Item</a>';
            $productId ='43';
            $this->getChild('review_form')->setData('productId', $productId);
            echo $this->getChildHtml('review_form', false);
            echo "</div>";

            /**echo "<div class='previous-button'>";
            echo '<button type="button" title="Add to Cart" class="button btn-cart" onclick="setLocation(\'';
            echo $this->helper('checkout/cart')->getAddUrl($_product);
            echo '\')"><span><span>Order Again</span></span></button>';
            echo "</div>";**/

            ?>

            <?php $i = $_product->getId();?>

            <div class='previous-button'>

                <form action="<?php echo $this->helper('checkout/cart')->getAddUrl($_product); ?>" method="post" id="product_addtocart_form_<?php echo $_product->getId()?>"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>


                <?php if($_product->isSaleable()): ?>

                    <input type="text" name="qty" id="qty<?php echo $i;?>" maxlength="12" value="1" title="Qty" class="cartnum" />

                    <?php $qtyforaction = 'qty'.$i; ?>

                    <script type="text/javascript">
                    var qty = document.getElementById('qty').value;
                    document.getElementById('buttonaddcart').innerHTML = '<button type="button" class="addtocartbutton" onclick="setLocation(\'' + url + 'qty/' + qty + '/\')"></button>';
                    </script>


                    <div id="buttonaddcart">

                        <button type="button" class="addtocartbutton button btn-cart" onclick="setLocation('<?php echo $this->helper('checkout/cart')->getAddUrl($_product); ?>qty/')" >
                            <span><span>Order Again</span></span>
                        </button>

                    </div>          

                <?php else: ?>

                    <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>

                <?php endif; ?>

                </form>

            </div>


            <?php

            echo "<div class='previous-clear'></div>";

            echo "</li>";

    }
}
}
?> 
请尝试以下方法:

echo $this->getChildHtml('review_form'); 
此外,如果您想要检索产品id,这完全取决于您的自定义页面的加载方式。我假设您使用的是自定义控制器,它是使用寄存器的最佳位置:

Mage::register('current_product', $product);

然后您可以在模板文件中调用Mage::registry'current_product'。

我已经尝试了echo$this->getChildHtml'review_form';这也不行吗?请注意,您可以删除引用的XML中的模板定义。它是在块级别定义的。此外,您还应该在mymodule/myblock.phtml中创建并调用getChildHtml-希望它有意义非常感谢!表单通过并填写行确保您的自定义URL具有在ID参数下定义的产品ID。所以你的控制器/你的动作/id/产品id在这里。或者将$this->getAction替换为Mage::getUrl'review/product/post',数组'id'=>$productId;我在php循环中有这段代码,所以我现在不确定如何每次都能获得唯一的产品id?现在是空白的吗?
Mage::register('current_product', $product);