I'm still a bit green to this, so please forgive me.
I'm using 2.3.2.
I created a banner upload in page.php to allow a unique banner image for each page. It works beautifully.
Then, I tried to create the staff page, per the tutorial.
But, the tab I've created for the staff photo isn't showing up in the CMS.
See my code below:
Page.php
<?php
class Page extends SiteTree {
public static $db = array(
);
public static $has_one = array(
'BannerImage' => 'Image'
);
function getCMSFields() {
$fields = parent::getCMSFields();
if($this->ClassName == "Page"){
$fields->addFieldToTab("Root.Content.PgBannerImage", new ImageField("BannerImage"));
}
return $fields;
}
}
class Page_BannerImage extends Image {
function generatePageBanner($gd) {
$gd->setQuality(80);
return $gd->paddedResize(890,200);
}
}
class Page_Controller extends ContentController {
public function init() {
parent::init();
// Note: you should use SS template require tags inside your templates
// instead of putting Requirements calls here. However these are
// included so that our older themes still work
//Requirements::themedCSS("layout");
//Requirements::themedCSS("typography");
//Requirements::themedCSS("form");
}
/**
* Site search form
*/
function SearchForm() {
$searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : 'Search';
$fields = new FieldSet(
new TextField("Search", "", $searchText)
);
$actions = new FieldSet(
new FormAction('results', 'Search')
);
return new SearchForm($this, "SearchForm", $fields, $actions);
}
/**
* Process and render search results
*/
function results($data, $form){
$data = array(
'Results' => $form->getResults(),
'Query' => $form->getSearchQuery(),
'Title' => 'Search Results'
);
return $this->customise($data)->renderWith(array('Page_results', 'Page'));
}
}
?>
ProductsPage.php (It will be used to display products, rather than staff, so it's named accordingly...)
<?php
/**
* Defines the ProductsPage page type
*/
class ProductsPage extends Page {
static $db = array(
);
static $has_one = array(
'ProdPhoto' => 'Image'
);
}
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Images", new ImageField("ProdPhoto"));
return $fields;
}
class ProductsPage_Controller extends Page_Controller {
}
?>
I've my pages working correctly to display the information. I just can't get the photos to upload.
Please let me know if more information is needed or if I'm making an obvious error.
Thanks!