JoomailerChimp not shortening K2 articles to intro text

More
07 Jan 2011 17:29 #626 by fezzicnex
I'm using K2 and my members are able to write article and contribute to the site's blog. They generally put the whole article in the content tab and let K2 automatically shorten it on the homepage (meaning they dont specifically put they're own read more link in).

So when i send out the newsletter, the content is the full article with no pictures. Is there any way to fix this and get Joomailer to shorten the article like K2 does?

Please Log in or Create an account to join the conversation.

  • The Mole
  • Visitor
  • Visitor
17 Mar 2011 14:44 #840 by The Mole
Hi ,

I've just posted a similar message, I notice you haven't had a reply though. Did you manage to find out how to do this?

Thanks

Mark

Please Log in or Create an account to join the conversation.

More
22 Mar 2011 20:30 #847 by pete
Hi guys,

This feature is currently not on our todo list so I'll provide instructions how to solve in the meantime.

You have to edit the file /administrator/components/com_joomailermailchimpintegration/controllers/create.php

Scroll down to the very end. Above the closing curly brackets where it says "}// class" enter the following function:
Code:
// Original PHP code by Chirp Internet: www.chirp.com.au function truncateText($string, $limit, $break=".", $pad="...") { //return with no change if string is shorter than $limit if(strlen($string) <= $limit) return $string; // is $break present between $limit and the end of the string? if(false !== ($breakpoint = strpos($string, $break, $limit))) { if($breakpoint < strlen($string) - 1) { $string = substr($string, 0, $breakpoint) . $pad; } } return $string; }

Then replace line 308 and 1324 with this code:
Code:
$html_content = $this->truncateText( $art->introtext, 300 );
(These line numbers refer to version 1.5.4)

The 300 means the function will count 300 characters and cut off the text at the next following point and then attach three points.

Please keep in mind that after each joomailer upgrade you will have to apply this patch again!

Let me know if this is what you're looking for and if not, why ;)

Kind regards,
Pete

Please Log in or Create an account to join the conversation.

More
28 Apr 2011 07:47 #1032 by empea
Hi Pete
Thanks so much for this patch - just implemented and it's working beautifully :) You saved the day!!
I've just made another post regarding inserting k2 item images along with intro text k2 images - do you have any ideas how I could achieve this?

Thanks again
Emily ;)

Please Log in or Create an account to join the conversation.

More
29 Apr 2011 05:44 #1087 by empea
I've just send myself a test message and noticed that in k2 items my text is truncated in the middle of a hyperlink. This means that the readmore link is not displaying correctly. I've been looking for a way to alter the truncate function to fix or strip broken html. I found this
Code:
if ( $tidy_html == 1 ) { ob_start( ); $tidy = new tidy; $config = array( 'indent' => true, 'output-xhtml' => true, 'wrap' => 200, 'clean' => true, 'show-body-only' => true ); $tidy->parseString( $input, $config, 'utf8' ); $tidy->cleanRepair( ); $input = $tidy; } if ( $strip_html == 1 ) { $input = strip_tags( $input ); }
which looks promising - but not sure how to implement in the Pete's patch...

Any suggestions?
Cheers
Emily

Please Log in or Create an account to join the conversation.

More
29 Apr 2011 06:01 #1088 by empea
Did some more searching and think I've found a way to fix it. Instead of
Code:
$html_content .= $this->truncateText( $art->introtext, 350);

I used
Code:
$html_content .= $this->truncateText( $art->introtext, 350, " ");

Seems to be working so far.

Please Log in or Create an account to join the conversation.

  • The Mole
  • Visitor
  • Visitor
05 May 2011 20:41 #1117 by The Mole
Hi,

I've used this code before to shorten the K2 articles but I have just upgraded Joomlamailer to version 1.7 and made these changes above and it doesn't seem to be working, any ideas?

Thanks

Mark

Please Log in or Create an account to join the conversation.

  • The Mole
  • Visitor
  • Visitor
11 May 2011 20:46 #1151 by The Mole
Hi,

Could anyone help me with the above problem?? I have upgraded to the latest version and I don't think the code suggested previously works now, can you please confirm?

Thank you
Mark

Please Log in or Create an account to join the conversation.

More
13 May 2011 14:00 #1161 by pete
Hello Mrk,

I have no idea why it wouldn't work with the new version except the line numbers where you have to adjust the code have changed. However, please download the attached file, extract it and upload the file create.php to your server to the directory: /administrator/components/com_joomailermailchimpintegration/controllers

download

Please Log in or Create an account to join the conversation.