久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Magento 中以編程方式確定是否在產品頁面上

Determine if on product page programmatically in Magento(在 Magento 中以編程方式確定是否在產品頁面上)
本文介紹了在 Magento 中以編程方式確定是否在產品頁面上的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想在 Magento 站點的所有頁面上插入跟蹤代碼,如果頁面是 CMS 頁面、類別瀏覽頁面或產品查看頁面,則需要使用不同的語法.我有一個自定義模塊,其中設置了一個塊,現在可以在每個頁面上插入通用跟蹤代碼.從區塊內部,如何區分CMS頁面、分類頁面和產品頁面?

I want to insert tracking codes on all of the pages of a Magento site, and need to use a different syntax if the page is a CMS page, a category browsing page, or a product view page. I have a custom module set up with a block that inserts a generic tracking code on each page for now. From within the block, how can I distinguish between CMS pages, category pages, and product pages?

我開始于:

Mage::app()->getRequest();

我可以看到

Mage::app()->getRequest()->getParam('id');

返回產品和類別頁面上的產品或類別 ID,但不區分這些頁面類型.

returns the product or category ID on product and category pages, but doesn't distinguish between those page types.

Mage::app()->getRequest()->getRouteName();

CMS 頁面返回cms",但類別瀏覽和產品查看頁面都返回catalog",所以我不能用它來區分類別和產品頁面.

return "cms" for CMS pages, but returns "catalog" for both category browsing and product view pages, so I can't use that to tell category and product pages apart.

請求中是否有我可以安全使用的指示符?或者有沒有更好的方法來實現我針對不同頁面類型使用不同跟蹤代碼的目標?

Is there some indicator in the request I can use safely? Or is there a better way to accomplish my goal of different tracking codes for different page types?

推薦答案

使用路由器可能有更好的方法來做到這一點,但一種快速的方法是檢查注冊表以查看我們是否有我們正在使用的單個產品看著:

There may be an even better way to do this using routers, but one fast way is to check the registry to see if we have a single product that we are looking at:

<?php

$onCatalog = false;
if(Mage::registry('current_product')) {
    $onCatalog = true;
}

希望有幫助!

謝謝,喬

這篇關于在 Magento 中以編程方式確定是否在產品頁面上的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 在线视频一区二区三区 | 99精品国产一区二区三区 | 精品国产一区二区三区久久狼黑人 | 美日韩中文字幕 | 欧美一区二区黄 | 日日干干夜夜 | 91视频播放 | 日本小电影网站 | 女人牲交视频一级毛片 | 99久久精品一区二区成人 | 美女国内精品自产拍在线播放 | 国产在线97 | 中文字幕av亚洲精品一部二部 | 国产欧美一区二区三区在线看 | 国产一区二区三区亚洲 | 亚洲成人综合在线 | 美女一区二区在线观看 | 中文字幕 欧美 日韩 | 日韩一级免费看 | 久久国产成人 | 国产精品久久久久久久久 | 久久精品国产一区二区三区 | 69av在线视频 | 日韩欧美一区二区三区免费观看 | 成人免费视频一区二区 | 91久久久www播放日本观看 | 在线91| 午夜影院视频 | 亚洲高清一区二区三区 | 精品视频久久久久久 | 91麻豆精品国产91久久久更新资源速度超快 | 蜜桃官网 | 香蕉一区二区 | 成人免费视屏 | 日本中文字幕在线观看 | 中文字幕1区 | 国产98色在线 | 日韩 | 久久综合一区 | 国产成人精品久久 | 涩爱av一区二区三区 | 精品欧美激情精品一区 |