Monday, January 3, 2011

Re: paginate posts substring body which uses tinymce - do i substr in the paginate or at the view?

On Mon, Jan 3, 2011 at 9:36 AM, Jon Bennett <jmbennett@gmail.com> wrote:
>> i am so ignorant.
>>
>> http://book.cakephp.org/view/1625/truncate
>>
>> this is the solution and a great one.
>
> If the content comes from TinyMCE, it'll be html - so you could also
> just strip off the first paragraph and show that in full, rather than
> show part of a paragraph, something like
> http://davidwalsh.name/php-paragraph-regular-expression would do it.
> You could easily wrap that into a helper method, or if you need it in
> a lot of places, you could grab in the afterFind of your model and add
> an extra field to your dataset.

In addition to the above, you can also do the truncating in the
add/edit methods by including a new column in the table, intro. Then,
before saving a Post, add a new key, 'intro', to the data with the
truncated body/content as value. By doing it this way, you can specify
that you want the intro column, not body/content in your $paginate.
Otherwise, you'll be needlessly fetching the entire content of each
Post in index action.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: