want to call one phtml file in another phtml file using anchor tag

前端 未结 6 829
迷失自我
迷失自我 2021-02-06 16:47

I\'m using Magento.

I want display and call one phtml file as a link in another phtml file…

I have the new.phtml file on t

相关标签:
6条回答
  • 2021-02-06 17:16

    you call newproductpage.phtml in any phtml file using below code

    <?php echo $this->getLayout()->createBlock('core/template')->setTemplate('custom/newproductpage.phtml')->toHtml(); ?>
    
    0 讨论(0)
  • 2021-02-06 17:27

    Use the below code for rendering your phtml file in another phtml file.

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

    For more refinement of your code, you can use the block name and block file name instead of core/template because core/template use the core resources.

    0 讨论(0)
  • 2021-02-06 17:30
    <?php echo $this->getLayout()->createBlock('core/template')->setTemplate('catalog/product/new.phtml')->toHtml(); ?>
    

    you can also check the link.

    Display .phtml page in another .phtml page

    0 讨论(0)
  • 2021-02-06 17:32

    You can not call directly one phtml file to another phtml file.

    But there are two way to call your phtml file either create one controller and create one action and call action from your anchor tag or create one cms page which call your phtml file.

    if you create one module, so in your layout file something you can write

    <modulename_controllername_controlleraction>
        <reference name="content">
            <block type="catalog/product_new" template="custom/newproductpage.phtml" />
        </reference>
    </module_controllername_controlleraction>
    

    Or you can directly put this code in your cms page content area

    {{block type="catalog/product_new" template="custom/newproductpage.phtml"}}
    

    and in anchor tag give cms page link.

    0 讨论(0)
  • 2021-02-06 17:34

    I believe you and I want to do precisely the same thing. I'm creating a modal from bootstrap and I need to call in a partial using the href attr.

    So far, I think this might be possible by creating a page in the CMS and then using something like this:

    <li><a href="<?php echo $this->getUrl("page-name-in-CMS") ?>">Home</a></li>
    

    But honestly, I'm just starting out with Magento and know very little.

    0 讨论(0)
  • 2021-02-06 17:39

    you can use iframe for same and load this another page content using AJAX call

    0 讨论(0)
提交回复
热议问题