Hey Evryone,
Im parsing a Atom Feed in a snippet to output a Chunk whith the parsed articles. i first was using php code to limit the article length but after that i found that here is a build in MODx modifier. when using the ellipsis on my chunk the sentence is cut short however not like i expected. here is a example:
Cunk:
<li>
<h2><a href="[[+link]]" title="[[+title]]" rel="nofollow" target="_blank">[[+title:ellipsis=`30`]]</a></h2>
<div class="image"><a href="[[+link]]" rel="nofollow" ttarget="_blank"><img alt="alt_example" src="assets/images/media/full/6.jpg"/></a></div>
<div class="content">
<p>[[+content:ellipsis=`193`]]</p>
<div class="info">
<a href="[[+link]]" class="read_more" rel="nofollow" target="_blank">read more</a>
</div>
</div>
</li>
Snippet:
$aArticle = array('link' => 'http://www.example.com', 'title' => 'Lorem ipsum dolor sit amet, consectetur cras amet.', 'content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus placerat vitae tortor ac luctus. Duis eros velit, aliquam ut maximus ac, pellentesque non erat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus posuere.');
Some code...
$sChunks .= $modx->getChunk('MychunkName', $aArticle);
...Some more code
when the chunk is parsed it will output like this:
<h2><a href="http://www.example.com" title="Lorem ipsum dolor sit amet, consectetur cras amet." rel="nofollow" target="_blank">Lorem ipsum dolor sit amet, consectetur...</a></h2>
<div class="image"><a href="http://www.example.com" rel="nofollow" ttarget="_blank"><img alt="alt_example" src="assets/images/media/full/6.jpg"/></a></div>
<div class="content">
<p>sit amet, consectetur adipiscing elit. Vivamus placerat vitae tortor ac luctus. Duis eros velit, aliquam ut maximus ac, pellentesque non erat. Cum sociis natoque penatibus et magnis...</p>
<div class="info">
<a href="http://www.example.com" class="read_more" rel="nofollow" target="_blank">read more</a>
</div>
</div>
Both the title and the Content are cut of at the given limit but it will not cut word words in half causing the text to be 3 or more characters to long in some cases. If the last word would be longer lets say it had 4 extra caraters then the output would be 7 caracters to long.
My question is can i cut the words in half ?
Example
Lorem ipsum dolor sit amet, consecte...
instead of
Lorem ipsum dolor sit amet, consectetur...