Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.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 CMS页面中的PHP代码未使用自定义模板呈现_Php_Html_Magento_Content Management System - Fatal编程技术网

Magento CMS页面中的PHP代码未使用自定义模板呈现

Magento CMS页面中的PHP代码未使用自定义模板呈现,php,html,magento,content-management-system,Php,Html,Magento,Content Management System,我试图在Magento的CMS页面上使用一些PHP。我试过了,但运气不好。当我检查它时,html在那里,但它不执行php代码 我在页面目录中创建了文件characterized_solutions.phtml。以下是该文件的内容 <h2>Featured Solutions</h2> <p>Our Featured VoIP Solutions are selected by our experienced engineers to be Industry

我试图在Magento的CMS页面上使用一些PHP。我试过了,但运气不好。当我检查它时,html在那里,但它不执行php代码

我在页面目录中创建了文件characterized_solutions.phtml。以下是该文件的内容

<h2>Featured Solutions</h2>

<p>Our Featured VoIP Solutions are selected by our experienced engineers to be Industry leading technologies that you’ll want to consider when choosing the best VoIP solution for your business or customers.</p>

<p>With in-depth VoIP product overviews and reviews, tutorials and videos, our Featured VoIP Solutions will advise you on what VoIP equipment to use, how to implement it, and why you should choose it.</p>

<div class="featured-solutions">
<?php
    $directory="/skin/frontend/default/ultimento-custom/images/featured";
    $featured_images = preg_grep('/^([^.])/', scandir ($directory));
    $count=1;

    foreach ($featured_images as $feat){
        $feat_solution = basename($feat, ".png");
        if($count % 3 == 0) { ?>
        <div class="featured-right">
        <?php } else { ?>
        <div class="featured-left">
        <?php }
        echo '<a class="featured" href="../featured-solution/'.$feat_solution.'">
              <img src="/skin/frontend/default/ultimento-custom/images/featured/'.$feat.'" class="img-featured" />
              <p>Featured Solution: '.$feat_solution.'</p>
              </a>
              </div>';

        $count++;
    }
?>    
</div>
结果是,执行的是html,而不是PHP。标签内的任何内容都不会显示


知道我做错了什么吗?谢谢

AleksandrIvashchenko指出我错过了一次机会。在我的第一个/在我的$directory中

之前,我建议您添加一些错误的php代码进行调试,例如var_dump$featured_image;ff;在$featured_images=preg_grep'/^[^.]/'之后,scandir$目录;。如果执行此代码,您将知道它,并且您将知道变量$1中有多少文件_images@AleksandrIvashchenko我只是尝试了一下,在我的html下得到了NULL。另外,页面的其余部分也没有加载。这很好,因为函数ff未定义,并且您出现了致命错误,但您看到NULL。这意味着preg_grep没有返回任何结果。可能您使用了错误的路径。如果要调试,我首先建议将SetEnv MAGE_IS_DEVELOPER_MODE 1添加到.htaccess,下一步是scandir的调试结果。添加行var_dumpscandir$目录;ff;在$featured\u images=preg\u grep之前。。。并修复变量$directory在第一个斜杠$directory=/前忘记了一个点/frontend@AleksandrIvashchenko啊,当然是这样了,我忘了。在第一条斜线之前。谢谢你指出这一点。现在看来一切都好了。谢谢
{{block type="core/template" template="page/featured_solutions.phtml"}}