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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Product Portfolio

Go to End

12 Posts   5307 Views


Community Member, 121 Posts

18 April 2010 at 6:10pm


I'm trying to create a website for an Antique shop and was wondering how SilverStripe can handle product portfolios. I do not know of an existing module which can do this but I guess we have to use the DataObjectManager to create one ourselves? Can anyone help me start with this?

I really like what this one user did with his site:

But I think it would be better if clicking the image will bring it to a separate page for each product/item.

Thanks! :)


Forum Moderator, 4102 Posts

19 April 2010 at 3:58am

Edited: 19/04/2010 4:00am

Yeah, that's really easy to do with DOM. In this example, I'll assume you want to upload your own thumbnail rather than letting Silverstripe generate it for you..


class PortfolioPage extends Page
static $has_many = array (
'PortfolioItems' => 'PortfolioItem'

public function getCMSFields() {
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.Portfolio Items", new ImageDataObjectManager($this,'PortfolioItems','PortfolioItem','Thumbnail'));
return $f;

class PortfolioPage_Controller extends Page_Controller
public function show()
if($this->urlParams['ID'] && is_numeric($this->urlParams['ID'])) {
return array (
'PortfolioItem' => DataObject::get_by_id("PortfolioItem", $this->urlParams['ID']
return false;


class PortfolioItem extends DataObject
static $db = array (
'Title' => 'Text',
'Caption' => 'Text'
static $has_one = array (
'PortfolioPage' => 'PortfolioPage',
'Thumbnail' => 'Image',
'FullSize' => 'Image'

static $summary_fields = array (
'Title' => 'Title',
'Caption' => 'Caption'

public function getCMSFields()
return new FieldSet(
new TextField('Title'),
new TextareaField('Caption'),
new ImageField('Thumbnail'),
new ImageField('FullSize','Full size image')

public function Link()
return Controller::join_links($this->PortfolioPage()->Link(),'show',$this->ID);

<% control PortfolioItems %>
<li><a href="$Link">$Thumbnail.SetWidth(200)</a> 
<a href="$Link">$Title</a> $Caption</li>
<% end_control %>

<% if PortfolioItem %>
<% control PortfolioItem %>
<% end_control %>
<% else %>
That portfolio item was not found.
<% end_if %>

Might be some syntax errors in there, but that's what you get for a 90-second code sprint. :)



Forum Moderator, 4102 Posts

19 April 2010 at 4:04am

I would also add:




Community Member, 12 Posts

8 May 2010 at 7:19am

Could you then group the items by category? And add a little description to the category? Like in this template


Community Member, 12 Posts

11 May 2010 at 4:23pm

So, I got the portfolio page to display the items in categories on the page, what I can't figure out is how to then display them on their own pages. With the code provided I am getting a page that says this page does not exist...

My set up is this PortfolioHolder >PortfolioPage >PortfolioProject

There is one PortfolioPage for each category, with a DOM on each that manages the PortfolioProjects. I think that because I added this extra layer the show function is incorrect. Is there a right way to make the link go to portfolio/web-design/id ?

Any help is appreciated - I could build this in my sleep in WordPress and I am sure this is something I am over-thinking as with the categories.


Forum Moderator, 4102 Posts

11 May 2010 at 4:43pm

In that case, you just move everything down a level. The show() function goes on your PortfolioCategory page, and you create a _show template for the ProductCategory page, as well. Should be exactly the same code, just in a different class.


Community Member, 1 Post

11 June 2010 at 2:58am

This code is great - thanks Uncle Cheese!

Question- I keep getting this error code when I try to upload my larger image:

Call to a member function write() on a non-object in /home/content/g/o/u/gourmetsquare/html/ on line 209

Here's what I found on line 209 - $this->form->getRecord()->write();

Help please?


Community Member, 21 Posts

29 July 2010 at 6:23pm

Did this error ever get fixed ? Im running into it now, seems to only happen when creating a new record seems fine afterwards though.

Go to Top