简体   繁体   中英

PHP Code in Magento CMS Page Not Rendering With Custom Template

I'm trying to use some PHP on a CMS page in Magento. I tried this solution - but had no luck. When I check it, the html is there, but it doesn't execute the php code.

I created the file featured_solutions.phtml in the page directory. Here are the contents of that file

<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>

Then in my CMS page, I have this line

{{block type="core/template" template="page/featured_solutions.phtml"}}

The result is, the html is executed, but not the PHP. Anything inside the tags does not show up.

Any ideas what I'm doing wrong? Thanks!

AleksandrIvashchenko pointed out I was missing a . before my first / in my $directory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM