想要使用锚标记在另一个phtml文件中调用一个phtml文件

Bha*_*hah 4 php hyperlink magento

我正在使用Magento.

我想要显示并将一个phtml文件作为另一个phtml文件中的链接调用...

我new.phtml在主页上有该文件.在那我把一个链接CHECK ALL显示所有新产品作为类别页面..它看起来像类别页面.为此,我创建了另一个phtml名为的文件newproductpage.phtml,该文件的代码相同new.phtml.现在我尝试将此newproductpage.phtml文件@homepage称为CHECK ALL链接,因为我编写此代码....

<a href="<?php echo $this->getUr('newproductpage.phtml')?>">CHECK ALL</a>
Run Code Online (Sandbox Code Playgroud)

但它没有工作......

日Thnx ..

Dee*_*lah 16

你可以使用下面的代码在任何phtml文件中调用newproductpage.phtml

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('custom/newproductpage.phtml')->toHtml(); ?>
Run Code Online (Sandbox Code Playgroud)


小智 5

使用以下代码在另一个phtml文件中呈现phtml文件。

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('templatefolderpath/filename.phtml')->toHtml(); ?>
Run Code Online (Sandbox Code Playgroud)

为了进一步完善代码,可以使用块名和块文件名来代替core / template,因为core / template使用核心资源。