Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否有任何Magento代码可以从特定主题获取phtml文件路径?_Magento_Php - Fatal编程技术网

是否有任何Magento代码可以从特定主题获取phtml文件路径?

是否有任何Magento代码可以从特定主题获取phtml文件路径?,magento,php,Magento,Php,由于某些原因,我需要从移动主题访问phtml文件 是否有任何直接访问代码来实现此目的 比如说- Mage::app()->getLayout()->createBlock('core/template')->setTemplate('catalogsearch/form.mini.phtml')->toHtml(); 这段代码从默认主题返回搜索表单,但我需要从移动主题返回它 请帮忙 我认为你应该能够做这样的事情: // Switch to the desired the

由于某些原因,我需要从移动主题访问phtml文件

是否有任何直接访问代码来实现此目的

比如说-

Mage::app()->getLayout()->createBlock('core/template')->setTemplate('catalogsearch/form.mini.phtml')->toHtml();
这段代码从默认主题返回搜索表单,但我需要从移动主题返回它


请帮忙

我认为你应该能够做这样的事情:

// Switch to the desired theme
Mage::getDesign()->setArea('frontend') //Area (frontend|adminhtml)
->setPackageName('default') //Name of Package
->setTheme('mobile?'); // Name of theme

Mage::app()->getLayout()->createBlock('core/template')->setTemplate('catalogsearch/form.mini.phtml')->toHtml();
但我们知道,这将切换页面呈现其余部分的主题。。。之后你可能会得到意想不到的结果。您可能应该能够首先存储当前主题和软件包,然后使用以下方法进行恢复:

$currentPackage = Mage::getSingleton('core/design_package')->getPackageName();
$currentTheme = Mage::getSingleton('core/design_package')->getTheme('frontend');

// Your stuff...

Mage::getDesign()->setArea('frontend')
->setPackageName($currentPackage)
->setTheme($currentTheme);