Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

getPostExcerpt - Fishpig WordPress Integration Extension troubles
 
dMores
Jr. Member
 
Total Posts:  3
Joined:  2013-01-13
 

First of all I wanted to thank FishPig for making such an awesome plugin.
It combines my favorite CMS with Magento.

Now, I know how to get stuff done in WordPress. Loops, CPTs etc. no problem.

But I’m stumped in Magento, and seems like I’m even more stumped in Wordento/MagentPress.

How do I get my “Homepage” (the blog start page) to show only the excerpts of articles and not the whole text?

I changed list.phtml (in the app folder) to something like this:

<?php foreach($posts as $post): ?>
                
<li class="item">
                    
<?php // echo $this->getPostRenderer($post)->toHtml() ?>                    
                    
<h1><a href="<?php echo $post->getPermalink() ?>" title="<?php echo $this->htmlEscape($post->getPostTitle()) ?>"><?php echo $this->htmlEscape($post->getPostTitle()) ?></a></h1>
                    <
class="post-excerpt"><?php echo $post->getPostExcerpt() ?></p>
                </
li>
            
<?php endforeach; ?>

But it still gives me the whole content.

I also can’t use a “if ($this->canDisplayExcerpt())” thing because then it won’t show me anything.

My next step is to add the article image using this

<?php if ($this->canDisplayImage() && $post->getFeaturedImage()): ?>
                        
<class="post-image">
                            <
a href="<?php echo $post->getPermalink() ?>" title="<?php echo $this->htmlEscape($post->getPostTitle()) ?>"><img src="<?php echo $post->getFeaturedImage()->getAvailableImage() ?>" alt="<?php echo $this->escapeHtml($post->getPostTitle()) ?>" style="<?php if ($this->getThumbW()): ?>max-width:<?php echo $this->getThumbW() ?>px;<?php endif; ?><?php if ($this->getThumbH()): ?>max-height:<?php echo $this->getThumbH() ?>px;<?php endif; ?>"/></a>
                        </
p>
                    
<?php endif; ?>

but I tried this and it also won’t show ANYTHING (i.e. white page) when I keep the “canDisplayImage” bit.

So what am I doing wrong?

Please please please ... point me in the right direction because I am lost :(

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
dMores
Jr. Member
 
Total Posts:  3
Joined:  2013-01-13
 

Okay, I maybe figured out what the issue is: when the excerpts are empty, the entire text is shown.
Why is there no auto-excerpt generator thingie?

Why does this

<?php $post->setExcerptSize($this->getExcerptLength()) ?>
not work?

Why will this

<?php if ($this->canDisplayExcerpt()): ?>
and this
<?php if ($this->canDisplayImage() && $post->getFeaturedImage()): ?>
break my page?
 
Magento Community Magento Community
Magento Community
Magento Community
 
derektraynor
Jr. Member
 
Total Posts:  1
Joined:  2012-12-24
 

Hi Dmores,

Did you solve how to get excerpts showing on the WP homepage?

 
Magento Community Magento Community
Magento Community
Magento Community
 
kieranjfahy
Jr. Member
 
Total Posts:  6
Joined:  2011-05-13
 

Hi,

I have found a solution to your problem.

Open the file app/design/frontend/base/default/template/wordpress/posts/list/renderer/default.phtml

around line 21 you should alter the code to look like this

<?php if ($this->displayExcerptInFeed() || $post->hasMoreTag()): ?>
                <?php 
//echo $post->getPostExcerpt() ?>
                
<class="post-excerpt"><?php $content $post->getPostExcerpt(); $content strip_tags($content); echo substr($content0500); ?> ...</p>
            
<?php else: ?>
                <?php 
echo $post->getPostContent() ?>
            <?php 
endif; ?>

I know it’s not a perfect solution, but it should be okay until a proper solution is found.

 
Magento Community Magento Community
Magento Community
Magento Community
 
swamyg1
Jr. Member
 
Total Posts:  5
Joined:  2011-01-13
 

I am using the above posted solution, has anyone improved this at all in the last several months?

 
Magento Community Magento Community
Magento Community
Magento Community
 
vswilsond
Jr. Member
 
Total Posts:  2
Joined:  2014-03-18
 

Yeah I am confronting this issue as well. It seems the only other way is to add a More Tag to the post itself, which does solve the problem as the code does interpret More Tags, however, when you have a large amount of blogs and don’t want to alter each one or write a script to do the job for you (and save it permanently in the post), then echo’ing a substr seems to be the only option until Fishpig can write in that kind of functionality. Unless you want to rewrite the model and manipulate the data in magento when it is read. Seems more hassle than it’s worth and would have to be disabled when it is implemented officially.

Edit: Also you should copy this file to your theme folder instead of altering base default, as that is the fallback for when it does not exist in the theme you use, so copy to app/design/frontend/yourpackage/yourtheme/template/wordpress/posts/list/renderer/default.phtml first before editing.

 
Magento Community Magento Community
Magento Community
Magento Community
 
LuckyDev
Jr. Member
 
Total Posts:  2
Joined:  2011-03-16
 

I am continuing to use the above solution in my Magento/Wordpress Integration, but have made one small change to improve it.
I am not just cutting it off at 700 characters, I am finding the nearest space so that I don’t chop it off mid-word.

See the strpos function included below…

echo substr($content0strpos($content' ',700));

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top