7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » [SOLVED] Display summary of object?
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 691 Views |
-
[SOLVED] Display summary of object?

21 August 2009 at 4:04am Last edited: 21 August 2009 9:49pm
Hi,
I've got DOM working nicely, but I wondered is there a way to only show a few characters / first sentence of a returned field?
I've got three columns showing - date (date), author (text), and article content (html text) - and would like to just show the first few words of the article content as a summary, so that the table isn't huge!
I've had a look through the forum but can't see if anyone has managed to do this yet, or even requested it.
Cheers
L
-
Re: [SOLVED] Display summary of object?

21 August 2009 at 4:29am
In your headings array just use 'ArticleContent.FirstSentence' => 'Article Content (summary')
-
Re: [SOLVED] Display summary of object?

21 August 2009 at 4:35am
Thanks again for the quick reply, but I get:
Uncaught Exception: Object->__call(): the method 'newscontent' does not exist on 'NewsArticle'
when I try your suggestion (I called the field NewsContent instead of ArticleContent in the end).
This is the call I'm using that blows up:
$f->addFieldToTab("Root.Content.NewsArticles", new DataObjectManager(
$this,
'NewsArticles',
'NewsArticle',
array('Date' => 'Date','Author'=>'Author','NewsContent.FirstSentence' => 'NewsContent'),
'getCMSFields_forPopup'
));Cheers
-
Re: [SOLVED] Display summary of object?

21 August 2009 at 5:12am
Just do this
getShortNewsContent()
{
return $this->obj('NewsContent')->FirstSentence();
}'ShortNewsContent' => 'Short news content'
-
Re: [SOLVED] Display summary of object?

21 August 2009 at 9:49pm
Yup, that worked a treat!
Thanks again UC.
L
| 691 Views | ||
|
Page:
1
|
Go to Top |

