I'm using the Aheadworks Blog Module for Magento 2. I'm trying to remove the post content from the blog listing page. I believe I need to edit the aw_blog_post_list.xml file, so I created a new copy of that file in my theme at app/design/frontend/[Vendor]/[theme]/Aheadworks_Blog/layout/aw_blog_post_list.xml. My code is below. I need it to only show the blog post header, featured image and author. NO content.
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="aw_blog_disqus"/>
<body>
<referenceContainer name="content">
<block class="Aheadworks\Blog\Block\PostList" name="aw_blog_post.list" template="post/list.phtml">
<block class="Aheadworks\Blog\Block\Post" name="aw_blog_post">
<block class="Aheadworks\Blog\Block\PostImage" name="aw_blog_post.post_image">
<arguments>
<argument name="view_model" xsi:type="object">Aheadworks\Blog\ViewModel\PostImage</argument>
<argument name="img_class" xsi:type="string">blog-post-featured-image</argument>
</arguments>
</block>
<arguments>
<argument name="mode" xsi:type="string">list_item</argument>
<argument name="view_model" xsi:type="object">Aheadworks\Blog\ViewModel\Post</argument>
<argument name="social_icons_block" xsi:type="string">Aheadworks\Blog\Block\Sharethis</argument>
</arguments>
</block>
<block class="Aheadworks\Blog\Block\Html\Pager" name="aw_blog_post.list.pager" as="pager" template="Aheadworks_Blog::pager.phtml">
<arguments>
<argument name="repository" xsi:type="string">Aheadworks\Blog\Api\PostRepositoryInterface</argument>
</arguments>
</block>
</block>
</referenceContainer>
</body>
</page>
I've been unable to find any useful information online. I've also tried troubleshooting with the help of ChatGPT. It helped in finding the correct file, but hasn't helped me solve the problem yet.
After much trial and error I found the solution! In case it helps someone in the future, my solution is below.
I created a new post template at app/design/frontend/[Vendor]/[theme]/Aheadworks_Blog/templates/post_no_content.phtml
. It is an exact copy of post.phtml
with these lines removed:
<div class="blog-post-content">
<?php /* @noEscape */ echo $block->getContent($post) ?>
</div>
<?php if ($block->showReadMoreButton($post)): ?>
<p class="blog-post-read-more-wrapper">
<a href="<?php /* @noEscape */ echo rtrim($block->escapeXssInUrl($block->getPostUrl($post)), '/') ?>"
class="blog-post-read-more action">
<?php echo $block->escapeHtml(__('Read more')) ?>
</a>
</p>
<?php endif; ?>
Then in my src/app/design/frontend/[Vendor]/[theme]/Aheadworks_Blog/layout/aw_blog_post_list.xml
file, I added template="Aheadworks_Blog::post_no_content.phtml
to the aw_blog_post
block like so:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="aw_blog_disqus"/>
<body>
<referenceContainer name="content">
<block class="Aheadworks\Blog\Block\PostList" name="aw_blog_post.list" template="post/list.phtml">
<block class="Aheadworks\Blog\Block\Post" name="aw_blog_post" template="Aheadworks_Blog::post_no_content.phtml">
<block class="Aheadworks\Blog\Block\PostImage" name="aw_blog_post.post_image">
<arguments>
<argument name="view_model" xsi:type="object">Aheadworks\Blog\ViewModel\PostImage</argument>
<argument name="img_class" xsi:type="string">blog-post-featured-image</argument>
</arguments>
</block>
<arguments>
<argument name="mode" xsi:type="string">list_item</argument>
<argument name="view_model" xsi:type="object">Aheadworks\Blog\ViewModel\Post</argument>
<argument name="social_icons_block" xsi:type="string">Aheadworks\Blog\Block\Sharethis</argument>
</arguments>
</block>
<block class="Aheadworks\Blog\Block\Html\Pager" name="aw_blog_post.list.pager" as="pager" template="Aheadworks_Blog::pager.phtml">
<arguments>
<argument name="repository" xsi:type="string">Aheadworks\Blog\Api\PostRepositoryInterface</argument>
</arguments>
</block>
<referenceBlock name="aw_blog_post.list.container.list.post_content" remove="true" />
</block>
</referenceContainer>
</body>
</page>
My blog listing page now shows only the info I want, without the full post content.