如何在magento中应用特定页面的条件?

时间:2016-10-26 05:28:59

标签: magento url conditional-statements

我想申请来自网址的特定网页的条件。它既不是类别页面也不是自定义cms页面。 Url就像localhost / project / index.php / news / blog.html。我想为这个'news / blog.html'申请条件。新闻或博客不是一个类别,也不是任何cms页面。有人能帮助我吗?

2 个答案:

答案 0 :(得分:0)

这取决于条件的类型,您希望在那里使用。您可以尝试以下方法。 1.尝试使用备忘单https://www.nicksays.co.uk/magento-events-cheat-sheet-1-5/将观察者放入相关控制器 2.直接尝试在该页面的模块中编辑模型。 3.尝试将一些代码直接放入文件中。

谢谢,

答案 1 :(得分:0)

使用以下代码。

Response {#224
  -reasonPhrase: "OK"
  -statusCode: 200
  -headers: array:7 [
    "Date" => array:1 [
      0 => "Sat, 29 Oct 2016 10:19:24 GMT"
    ]
    "Server" => array:1 [
      0 => "Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/7.0.9"
    ]
    "X-Powered-By" => array:1 [
      0 => "PHP/7.0.9"
    ]
    "Cache-Control" => array:1 [
      0 => "no-cache"
    ]
    "Set-Cookie" => array:1 [
      0 => "laravel_session=eyJpdiI6Ikx5WXJpTEFvZ0ZiNFwvbFwvYWZRQWxEZz09IiwidmFsdWUiOiJVM29lbTNYSnZwdld5ZHdVRk1IK1hJbG9RenNQa1owS1lRMEFYQ3lVamluV3JcL2RwaVQyRkpsZzkwQ082OU94QkJiSUpGQTZpeTMxWjdpMEtCZ1Byc3c9PSIsIm1hYyI6IjQwNTcwZTQ4YzQ2OGIwODQ5Y2NjMzBiMmIyNmI5MTVkNTY0ZjI0OGQ1Y2M1NTVjYTljNmU4Mjk2Nzg0Yjk2MmMifQ%3D%3D; expires=Sat, 29-Oct-2016 12:19:24 GMT; Max-Age=7200; path=/; HttpOnly"
    ]
    "Content-Length" => array:1 [
      0 => "4709"
    ]
    "Content-Type" => array:1 [
      0 => "text/html; charset=UTF-8"
    ]
  ]
  -headerNames: array:7 [
    "date" => "Date"
    "server" => "Server"
    "x-powered-by" => "X-Powered-By"
    "cache-control" => "Cache-Control"
    "set-cookie" => "Set-Cookie"
    "content-length" => "Content-Length"
    "content-type" => "Content-Type"
  ]
  -protocol: "1.1"
  -stream: Stream {#222
    -stream: stream resource @234
      wrapper_type: "PHP"
      stream_type: "TEMP"
      mode: "w+b"
      unread_bytes: 0
      seekable: true
      uri: "php://temp"
      options: []
    }
    -size: null
    -seekable: true
    -readable: true
    -writable: true
    -uri: "php://temp"
    -customMetadata: []
  }
}

它将为您的模块提供控制器名称。为此名称添加consition并编写代码。它肯定会起作用。