1

I would like to pull a from another phtml to my, how can I do this? I would like to use the same div that appears for the desktop cart for the mobile cart.

My Phtml

<div class="carrinho-cheio-mobile" style="display: none;">Itens in cart!</div>

Magento PHTML

<?php $_items = $this->getRecentItems(); ?>
<?php if (count($_items)): ?>
    <div id="header-cart" class="mini-cart-content dropdown-content left-hand skip-content skip-content- -style block-cart block">
        <div class="">

            <?php if ($tmpHtml = $this->getChildHtml('block_mini_cart_above_products')): ?>
                <div class="block_mini_cart_above_products"><?php echo $tmpHtml; ?></div>
            <?php endif; ?>

            <div class="block-subtitle"><?php echo $this->__('Recently added item(s)') ?></div>
            <ol id="cart-sidebar" class="mini-products-list clearer">
            <?php foreach($_items as $_item): ?>
                <?php echo $this->getItemHtml($_item) ?>
            <?php endforeach; ?>
            </ol>
            <script type="text/javascript">decorateList('cart-sidebar', 'none-recursive')</script>

            <div class="subtotal">
                <?php if ($canApplyMsrp): ?>
                    <span class="map-cart-sidebar-total"><?php echo $this->__('ORDER TOTAL WILL BE DISPLAYED BEFORE YOU SUBMIT THE ORDER'); ?></span>
                <?php else: ?>
                    <span class="label"><?php echo $this->__('Cart Subtotal:') ?></span> <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>
                    <?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>
                        <br />
                        <span class="incl-tax">(<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?> <?php echo Mage::helper('tax')->getIncExcText(true) ?>)</span>
                    <?php endif; ?>
                <?php endif; ?>
            </div>

            <div class="actions clearer">
                <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('View all items in your shopping cart')) ?>" class="button btn-inline-ver-carrinho" onclick="setLocation('<?php echo $this->getUrl('checkout/cart') ?>')"><span><span>Ver Carrinho</span></span></button>

                <?php if($_cartQty && $this->isPossibleOnepageCheckout()): ?>
                    <button type="button" class="button btn-checkout-finalizar-compra btn-inline" onclick="setLocation('<?php echo $this->getCheckoutUrl(); ?>')"><span><span>Finalizar<br>Compra</span></span></button>
                    <?php echo $this->getChildHtml('extra_actions') ?>
                <?php endif; ?>
            </div>

        </div> <!-- end: inner block -->
    </div> <!-- end: dropdown-content -->
<?php else: ?>
1

I'm also a bit confused at the question here. I know a simple way of calling another phtml from another however if this helps.

echo $this->getLayout()->createBlock('core/template')
->setTemplate('magento.phtml')->toHtml();

Change the block class and Magento template location and that should do the trick however.

1

I don't know if this is what your asking for but if you need to display some content block in another and maybe you want to remove the first, you have to do this:

1) Go go app/design/frontend/{package}/{theme}/template/custom/your_file_name.phtml then add the content of your code div, JS, php etc...

2) go to app/design/frontend/{package}/{theme}/layout/local.xml then add this:

<your_layout_handle> //layout handle of the page where you want to display the block
    <reference name="root">
        <block type="core/template" name="my.custom.block" template="custom/your_file_name.phtml" />
    </reference>
</your_layout_handle>

3) go to the page where you want to display the block that you created in the first step then add this:

<?php echo $this->getBlockHtml('my.custom.block') ?>

4) you can remove the block from some page like this:

<your_layout_handle> //layout handle of the page you want to remove this block
    <remove name="my.custom.block" />
</your_layout_handle>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.