我有一個執行代碼的文件(js.phtml)。我需要訪問一些用戶數據。當我在js.phtml中使用error_log($ this)時,它顯示「Mage_Core_Block_Template」 - 這讓我感到困惑。我期望這是父類,而不是傳遞給我的.phtml文件的類的價值。從Magento中的.phtml訪問自定義變量
那麼,我該如何與供應自定義對象或方法的一個.phtml文件?我是Magento的超級新手,我剛剛被放入任務中,因此我很抱歉使用錯誤的術語。
編輯: 我完整的文件路徑是:
- /app/design/frontend//default/template/customer/welcome/js.phtml
還有一個完整的模塊DIR這裏:
- /應用/代碼/本地//客戶/
編輯: 我需要訪問用戶國家和用戶ID。如果國家爲空,那也沒關係。
編輯: 我一直在做更多的研究,它看起來像我可以做這樣的事情: Current user in Magento?
但我還沒有在代碼中還沒有嘗試過....
編輯:想通了:
error_log(print_r(Mage::getSingleton('customer/session')->getCustomer()->getEntityId(), true));
error_log(print_r(Mage::getSingleton('customer/session')->getCustomer()->getCountry(), true));
您需要使用哪些對象/方法?你能描述一下你的js.phtml文件試圖完成什麼嗎? –
在OP中更新,好點。 –
你的路徑有問題。默認主題模板文件夾的路徑是'\ app \ design \ frontend \ base \ default \ template'。 – Zyava