1

Here I have a blog page there I wanted to display banner sliders. I configured the sliders they working fine in home page, but am unable to add in custom phtml(blog) page here is my blog Phtml file

<?php
    $this->getLayout()->createBlock("Magestore\Bannerslider\Block\SliderItem")->setSliderId(3)->toHtml();

    $blockObj= $block->getLayout()->createBlock('Mageplaza\Blog\Block\Listpost');
    $blockImageResize= $block->getLayout()->createBlock('Mageplaza\Blog\Block\Frontend');


    // $coll =  $blockObj->getPostCollection();


?>
<div>
    <?php
    ?>
</div>
<div class="mp-blog-rss">
    <a href="<?= $block->getRssUrl('post/rss') ?>" class="bb-rss-icon">
        <img src="<?= $this->getViewFileUrl('Mageplaza_Blog::media/images/rss.png') ?>" width="16px">
    </a>
</div>

What am doing wrong? can i get help? Thank you.

5
  • Is any errors in console? where is the code for slider in this file? Nov 27, 2019 at 6:25
  • @jafar pinjar Thank you for response. I added Extension of magestore banner slider. I configured in admin->Configuration. here inserting by $this->getLayout()->createBlock("Magestore\Bannerslider\Block\SliderItem")->setSliderId(3)->toHtml(); Nov 27, 2019 at 6:28
  • yes that's fine, so you added other extension for blog also? Nov 27, 2019 at 6:30
  • yes for blog i used Mageplaza Blog extension Nov 27, 2019 at 6:32
  • Is it working now? Nov 27, 2019 at 6:41

1 Answer 1

1

Please! Change your code

From

$this->getLayout()->createBlock("Magestore\Bannerslider\Block\SliderItem")->setSliderId(3)->toHtml();

To

echo $this->getLayout()->createBlock("Magestore\Bannerslider\Block\SliderItem")->setSliderId(3)->toHtml();

Hope this will help you!!

2
  • Thats a small miss, Thank you very much @jafar pinjar Nov 27, 2019 at 6:41
  • Happy to help!! Nov 27, 2019 at 6:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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