0

hi currently am looking for a solution to add catg image over breadcrumbs. i have added a static block inside catg and displaying both catg and product is there any solution for this.

i just want this image above the breadcrumbs. thanks in advance

enter image description here

update i have tried to override breadcrumbs.phtml file in my custom theme and called a static block and the result is working fine over catg page but this image is also visible on home page which i dont want. my phtml file

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>

<!-- calling block in phtml file -->
<?php
echo $this->getLayout()
->createBlock('Magento\Cms\Block\Block')
->setBlockId('catg-image')
->toHtml();
?>

<!-- breadcrumbs folows here -->
<?php if ($crumbs && is_array($crumbs)) : ?>
<div class="breadcrumbs">
    <ul class="items">
        <?php foreach ($crumbs as $crumbName => $crumbInfo) : ?>
            <li class="item <?= $block->escapeHtmlAttr($crumbName) ?>">
            <?php if ($crumbInfo['link']) : ?>
                <a href="<?= $block->escapeUrl($crumbInfo['link']) ?>"
                   title="<?= $block->escapeHtml($crumbInfo['title']) ?>">
                    <?= $block->escapeHtml($crumbInfo['label']) ?>
                </a>
            <?php elseif ($crumbInfo['last']) : ?>
                <strong><?= $block->escapeHtml($crumbInfo['label']) ?></strong>
            <?php else : ?>
                <?= $block->escapeHtml($crumbInfo['label']) ?>
            <?php endif; ?>
            </li>
        <?php endforeach; ?>
    </ul>
</div>
<?php endif; ?>

pls refer the image below enter image description here

enter image description here

update i have already solved this issue thank you if anyone needs and ans can post a question and i will help him

working .phtml code

<?php if ($crumbs && is_array($crumbs)) : ?>
<div class="breadcrumbs">




    <ul class="items">
        <?php foreach ($crumbs as $crumbName => $crumbInfo) : ?>
            <li class="item <?= $block->escapeHtmlAttr($crumbName) ?>">
            <?php if ($crumbInfo['link']) : ?>
                <a href="<?= $block->escapeUrl($crumbInfo['link']) ?>"
                   title="<?= $block->escapeHtml($crumbInfo['title']) ?>">
                    <?= $block->escapeHtml($crumbInfo['label']) ?>
                </a>
            <?php elseif ($crumbInfo['last']) : ?>
                <strong><?= $block->escapeHtml($crumbInfo['label']) ?></strong>
            <?php else : ?>
                <?= $block->escapeHtml($crumbInfo['label']) ?>
            <?php endif; ?>
            </li>
        <?php endforeach; ?>
    </ul>
</div>
<?php endif; ?>
3
  • this image is your category image? which is uploaded from backend category??? – Naresh Rupareliya Dec 28 '19 at 5:09
  • no its a block i just want to know how to ovreride breadcrumbs so that i can call my block above it in phtml file – Pramod Dec 28 '19 at 5:17
  • answer posted. check and let me know working or not – Naresh Rupareliya Dec 28 '19 at 5:40
3

You need to override breadcrumbs.phtml file under

app/design/frontend/Vendor/Theme/Magento_Theme/templates/html/breadcrumbs.phtml

and use the code below:

<?php
// call your block here
?>
<?php if ($crumbs && is_array($crumbs)) : ?>
<div class="breadcrumbs">
    <ul class="items">
        <?php foreach ($crumbs as $crumbName => $crumbInfo) : ?>
            <li class="item <?= $block->escapeHtmlAttr($crumbName) ?>">
            <?php if ($crumbInfo['link']) : ?>
                <a href="<?= $block->escapeUrl($crumbInfo['link']) ?>"
                   title="<?= $block->escapeHtml($crumbInfo['title']) ?>">
                    <?= $block->escapeHtml($crumbInfo['label']) ?>
                </a>
            <?php elseif ($crumbInfo['last']) : ?>
                <strong><?= $block->escapeHtml($crumbInfo['label']) ?></strong>
            <?php else : ?>
                <?= $block->escapeHtml($crumbInfo['label']) ?>
            <?php endif; ?>
            </li>
        <?php endforeach; ?>
    </ul>
</div>
<?php endif; ?>

Hope this will help you!

5
  • thnkss but i have already found a solution and am updating my phtml code – Pramod Dec 28 '19 at 5:40
  • between do you know how to display catg image above catg name??can we achieve this in same file – Pramod Dec 28 '19 at 5:55
  • yes you need to add block end of phtml file – Naresh Rupareliya Dec 28 '19 at 6:12
  • i want the same catg name that is displaying below breadcrumbs above it – Pramod Dec 28 '19 at 6:13
  • override catalog_category_view.xml file in your theme and put this line <move element="page.main.title" destination="page.top" before="breadcrumbs"/> – Naresh Rupareliya Dec 28 '19 at 6:18

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.