Magento/Zend不允许使用符号链接

Mar*_*ive 6 symlink zend-framework magento

任何人都知道为什么Magento不允许在app/design文件夹之外的模板.phtml文件的符号链接?

如果我在该文件夹中执行符号链接,它可以正常工作,但如果它在外部链接,则不起作用.所以它似乎是一些权限/安全性的东西,但我无法在任何地方找到任何信息.

可能是Zend设置?http://zend-framework-community.634137.n4.nabble.com/Zend-Tool-not-working-with-symbolic-links-in-include-path-td662569.html

任何人?

解决方法:感谢艾伦的建议,我发现了一个解决方法 - 因为我只是自己用于本地开发我很开心.如果这有助于其他任何人,我会在这里添加它.所以我在core/Mage/Core/Block/Template.php中插入以下内容,直接在Varien_Profiler :: start($ fileName)行之后;

    $storeId = Mage::app()->getStore()->getId();
    $theme = Mage::getStoreConfig('design/package/name', $storeId);
    Mage::Log($this->_viewDir.DS.$fileName); 
    $includes = $this->_viewDir.DS.$fileName; 
    if(strpos($includes, 'frontend/'.$theme )) { 
         include $this->_viewDir.DS.$fileName;
        };
Run Code Online (Sandbox Code Playgroud)

使用IF语句可以阻止任何基本模板加倍,并且只允许自定义主题模板通过.

Hen*_*wan 18

从Magento 1.5.1.0(可能是1.5.x?)开始,您可以在系统>配置>开发人员>模板设置>允许符号链接中启用一个选项.

不再需要肮脏的黑客/变通办法.:-)


小智 5

这是由于1.4.2中的变化导致Magento不再允许符号链接的文件夹.如果你看看Template.php

        $includeFilePath = realpath($this->_viewDir . DS . $fileName);
        if (strpos($includeFilePath, realpath($this->_viewDir)) === 0) {
            include $includeFilePath;
        } else {
            Mage::log('Not valid template file:'.$fileName, Zend_Log::CRIT, null, null, true);

        }
Run Code Online (Sandbox Code Playgroud)

如果模板不在"viewDir"下,你会发现它不会加载.