Php Magento:在外部页面上加载审阅表单

Php Magento:在外部页面上加载审阅表单,php,forms,magento,Php,Forms,Magento,默认情况下,审阅表单的Magento URL如下所示: www.domain.com/(producturl)-reviews#review-form. 但在本页中,评审表是评审页中的一个部分 我想在具有以下URL的唯一页面中加载审阅表单: www.domain.com/(producturl)-review-form. 此审查表仅适用于本产品 如何实现这一点?在审阅表单phtml文件中,直接调用审阅块 $this->getLayout() ->createBlock("rev

默认情况下,审阅表单的Magento URL如下所示:

www.domain.com/(producturl)-reviews#review-form.
但在本页中,评审表是评审页中的一个部分

我想在具有以下URL的唯一页面中加载审阅表单:

www.domain.com/(producturl)-review-form.
此审查表仅适用于本产品


如何实现这一点?

在审阅表单phtml文件中,直接调用审阅块

$this->getLayout()
 ->createBlock("review/product_view_list")
 ->setTemplate("review/product/view/list.phtml")
 ->toHtml();

您可以在xml布局文件中找到所有块名称和块模板(示例:)

在这种情况下,最好创建自定义路由,如
Mage\u Cms
模块

其中取决于使用自定义路由匹配的
请求路径
请求路径

  • modules->Mage\u Review

  • controller->ProductController.php

  • Action->listAction.

客户会这样看的

http://www.example.com/laptop1-review-form
但从内部来看,这一点很重要

http://www.example.com/review/product/list/id/33661/
这里

`laptop1` is  `product url_path` value
 `33661` is `product id` 

 `-reviews-form` suffix for review url as you want
  • 为此自定义模块创建自定义字体路由器

  • 4.从请求路径获取产品url并保存 如果请求路径包含
    review form
    ,则保存要求变量,然后从此字符串中删除
    review form

    $producturl=str_replace('-review-form','',$requestPathInfo)
    
  • 检查当前商店中的产品出口

  • 然后使用
    $producturl
    检查
    product

    $Rewrite=Mage::getModel('core/url_rewrite')
                        ->setStoreId(Mage::app()->getStore()->getId())
                        ->loadByRequestPath($identifier);
    
  • 设置内部请求模块、控制器、操作名称

  • 如果产品退出,则
    模块、控制器、此请求的操作。
    将命中哪个

    Mage_Review
    Module
    ProductController
    at
    listAction

    $request->setModuleName('review') 
                ->setControllerName('product')
                ->setActionName('list')
            ->setParam('id', $productid);
    
  • 最后,现在将请求别名设置为
    producturl审阅表单
    ,这样客户只能将laptop1审阅表单设置为审阅页面
  • 希望这对你有帮助

    你可以在

    在本模块中,我做了如下回顾:

    http://YOurmagentoInstanceurl/linen-blazer-585.html-review-form
    
    当任何产品url为时

    http://YOurmagentoInstanceurl/linen-blazer-585.html
    

    您需要为此定制扩展。@DeepKakkar,我该如何做?您所说的产品url是什么意思。。。。这种格式
    review/product/list/id/410/category/14/#review form
    @AmitBera我的意思是,我不想将其作为锚url加载到同一页面上。但是我想在一个单独的页面上加载评论表单,你能为当前评论URL和新URL添加一个示例URL吗谢谢!但是我怎样才能在它自己的页面上找到它呢?您必须创建一个本地模块来配置routing()和add-in方法_block、layout()以及您的review-form.phtml,并调用default review block为什么?您是否有任何错误消息或意外行为?没有,我可以按照说明完成。你能给我一个应该创建的本地模块的示例代码吗?非常感谢!我将Github的完整模块放在了我的商店中。但是我在哪里可以找到评论?我在哪里可以找到评论表?什么是URL的对立面
    linen-blazer-585.html
    是产品,然后您可以通过后缀添加
    -review form
    结束产品URL(
    linen-blazer-585.html review form
    $request->setModuleName('review') 
                ->setControllerName('product')
                ->setActionName('list')
            ->setParam('id', $productid);
    
    http://YOurmagentoInstanceurl/linen-blazer-585.html-review-form
    
    http://YOurmagentoInstanceurl/linen-blazer-585.html