Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

[SOLVED] Show related object title


5 Posts   1217 Views


21 August 2009 at 5:00am (Last edited: 21 August 2009 9:48pm), Community Member, 70 Posts

Ok, so this should be my last question for today! :)

I've managed to implement a relationship along with the DOM, but can't work out how to display the relationship in the admin page.

I've got a NewsArticle object with four fields: Date, Author, News content, and Category.

The Category is connected through a one -> many relationship (each article can have one category, category can have many articles).

I've got the DOM to display just the Category ID that's been assigned to the NewsArticle object - but would like to display (and filter by category).

Here's my code:

Does anyone know what I need to do to get it working?

Is there something basic I'm missing, or need to understand how the headers array can accept data?

All help is much appreciated!



21 August 2009 at 5:16am 4085 Posts

In your headings array, you should be able to do:

array('NewsCategory.Title' => 'News category title');

But if that doesn't work, just use a custom getter.

return $this->NewsCategory()->Title;

array('NewsCategoryTitle' => 'News category title');


21 August 2009 at 5:21am Community Member, 70 Posts

Hi Uncle Cheese,

I feel like a bit of a dolt this afternoon, but how do I implement a custom getter?

Does that need to be put in the header array, inside the getCMSFields function, or made as a function of its own in some way?

I tried NewsContent.Title, and it just returned the id with a hash (pound) symbol in front of it...




21 August 2009 at 5:38am 4085 Posts

You put the custom getter in the model for the class you're viewing in the DOM. In your case, that's NewsArticle, I believe.


21 August 2009 at 9:48pm Community Member, 70 Posts

Thanks for your help on this Uncle Cheese!

It's all working just as I need it to :)

I'll make a post with my final code so others can share at somepoint this weekend.