Hi all
I'm brand new to silverstripe, but have been cramming in tons of info thanks to this forum. I've even ALMOST got my site going bar this one problem. Following on from Tutorial 2's "Staff Section", I'm trying to create a product section in a similar vain.
The basic idea was:
PRODUCTS (Product Category Holder)
PRODUCT CATEGORIES
PRODUCTPAGE
The idea being that user would click on main products link, it would take them to a page listing all the categories of products available (possibly even with a picture), and then when user clicks on desired category, they'd get a list of all the products within that category.
So...
Adapting the code from Tutorial 2, I came up with 3 php files, code as follows:
<?php
class ProductCatsHolder extends Page {
static $db = array(
);
static $has_one = array(
);
static $allowed_children = array('ProductCats');
}
class ProductCatsHolder_Controller extends Page_Controller {
}
?>
<?php
class ProductCats extends Page {
static $db = array(
);
static $has_one = array(
'Photo' => 'Image'
);
static $allowed_children = array('ProductPage');
}
class ProductCats_Controller extends Page_Controller {
}
?>
<?php
class ProductPage extends Page {
static $db = array(
);
static $has_one = array(
'Photo' => 'Image'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo'));
return $fields;
}
}
class ProductPage_Controller extends Page_Controller {
}
?>
And this actually worked fine... with breadcrumbs and all. I could upload an image on the product pages, though they wouldn't show. Which I then figured might have been a CSS issue not set properly according to what I'd done.
Then I moved on to the next part of Tutorial 2, which was to create the associated .ss files. And as soon as I did, the whole product section crashed and burned. I didn't even get to do all the .ss files... it crashed and burned after I did the following for ProductCatsHolder.ss:
<% include Menu2 %>
<div id="Content" class="typography">
<% include Breadcrumbs %>
$Content
<ul id="ProductList">
<% control Children %>
<li>
<div class="productcatname"><a href="$Link">$Title</a></div>
<div class="productcatphoto">$Photo.SetWidth(50)</div>
<div class="productcatdescription"><p>$Content.FirstSentence</p></div>
</li>
<% end_control %>
</ul>
</div>
I don't know if I'm giving enough information - but any help is very much appreciated.
Thanks!
Trevor