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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

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

Generated with the default ContentController.ss template


Go to End


17 Posts   12152 Views

Avatar
clintonf

Community Member, 8 Posts

3 October 2010 at 9:39am

Hi,

I have the same issue after upgrading and suspect it will be the same thing as mentioned here....
Where is this file located?

"You do have class HomePage_Controller extends Page_Controller{} in your HomePage extends Page class?"

Thanks

Avatar
swaiba

Forum Moderator, 1899 Posts

4 October 2010 at 2:14am

"that file" is his own custom file, probably named HomePage.php to auto include it, it is unlikely to be your issue... When upgrading there is an odd bug that blanks out the class name of entries in Sitetree & Sitetree_Live that I have seen to then do the "Generated with the default ContentController.ss" error.

To fix (or just to check) open Sitetree & Sitetree_Live and for any rows without a class name add it back in.

Avatar
stevanovich

Community Member, 63 Posts

8 June 2011 at 9:07pm

For anyone who is interested, I screwed up my database by uploading old page controller (page.php) this deleted classes in the database therefore when i reinstated correct page controller the classes were still deleted. I had to go in and add the page classes manually, pain but better than dead database. Thus another way this could happen.

Avatar
wildflower1975

Community Member, 63 Posts

21 June 2011 at 4:43pm

I'm using SS 2.4.5 and have made an AboutPage class

class AboutPage extends SiteTree {
	public static $db = array(	);

	public static $has_one = array(	);
}
class AboutPage_Controller extends ContentController {
public function init() {
		parent::init();
}
}

but am getting the
Generated with the default ContentController.ss template
message

i've done the dev/build?flush=all and checked the AboutPage ClassName is in the Sitetree and SiteTree_Live records

if i put an AboutPage.ss in the templates dir it works
but if I rely on the default Page.ss to work like on the Tutorial 1 and for SS to pick up my AboutPage.ss template in the Layout dir - it doesn't
http://doc.silverstripe.org/sapphire/en/tutorials/1-building-a-basic-site

It looks like in removing the 'old' Page class and just having a SiteTree class this functionality has been broken?

Is there an explanation about this 'feature' I haven't found yet?
Maybe Tutorial 1 needs to be updated for 2.4.5?

thanks

Avatar
martimiz

Forum Moderator, 1391 Posts

22 June 2011 at 5:34am

Edited: 22/06/2011 5:36am

There is a link between the Page class and Page.ss. The ContentController will not default to Page.ss, since it knows nothing about it. For that to work you should have your controller extend Page_Controller instead. Unless you have serious reasons not to, I would suggest not removing the Page class, but using it to cover things that are valid for all pages, and base new Page types on it:

class AboutPage extends Page{
   public static $db = array(   );

   public static $has_one = array(   );
}
class AboutPage_Controller extends Page_Controller {
public function init() {
      parent::init();
}
}

Avatar
mhdesign

Community Member, 216 Posts

29 March 2012 at 10:28am

Edited: 29/03/2012 10:29am

Argh!! Struck this problem with a form on a couple of sites I have built this week!

My ContactPage.php file is:

//Model
class ContactPage extends Page
{
	static $db = array(
		'Mailto' => 'Varchar(100)', //Email address to send submissions to
		'SubmitText' => 'HTMLText' //Text presented after submitting message
	);
	
	//CMS fields
	function getCMSFields() 
	{
		$fields = parent::getCMSFields();
	
		$fields->addFieldToTab("Root.Content.OnSubmission", new TextField('Mailto', 'Email submissions to'));	
		$fields->addFieldToTab("Root.Content.OnSubmission", new HTMLEditorField('SubmitText', 'Text on Submission'));	
	
		return $fields;	
	}

}

// Controller
class ContactPage_Controller extends Page_Controller
{
	//Define our form function as allowed
	static $allowed_actions = array(
		'ContactForm'
	);
	
	//The function which generates our form
	function ContactForm() 
	{
      	// Create fields
	    $fields = new FieldSet(
		new LiteralField('', '<div class="stepone">'),
		new TextField('Name', 'Name*'),
		new TextareaField('StreetAddress', 'Street Address*'),
		new TextField('Telephone', 'Telephone*'),
		new EmailField('Email', 'Email*'),
		new TextareaField('Comments','Comments*'),
		new LiteralField('', '</div>')
		); 
	 	
	    // Create action
	    $actions = new FieldSet(
	    	new FormAction('SendContactForm', 'Send')
	    );
		
		// Create action
		$validator = new RequiredFields('Name', 'StreetAddress', 'Telephone', 'Email');
			
	    return new Form($this, 'ContactForm', $fields, $actions, $validator);
	}
 	
	//The function that handles our form submission
	function SendContactForm($data, $form) 
	{
	 	//Set data
		$From = $data['Email'];
		$To = $this->Mailto;
		$Subject = "Dawson Waste Services Limited Website message";  	  
		$email = new Email($From, $To, $Subject);
		//set template
		$email->setTemplate('ContactEmail');
		//populate template
		$email->populateTemplate($data);
		//send mail
		$email->send();
	  	//return to submitted message
		Director::redirect(Director::baseURL(). $this->URLSegment . "/?success=1");

	}

	//The function to test whether to display the Submit Text or not
	public function Success()
	{
		return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";
	}
}

For some dumb reason I can't change to the ContactPage page type in the CMS and save it - drop down menu still reads Change to Contact Page! Can anybody shed enlightenment?

Avatar
mhdesign

Community Member, 216 Posts

29 March 2012 at 11:48am

Scrapping the Content Page in the CMS and setting up a completely new page, then changing the page type to content page worked. Nothing wrong with the template code/PHP etc. at all. Go figure...

Avatar
dizzystuff

Community Member, 94 Posts

8 April 2012 at 2:47am

Looks like all is solved on this thread but adding this for future searches...

Had a similar problem recently to arthurdent, found that I had loaded my live db in dev environment, which was missing my XYZPage.php - so the rows in the Sitetree table with ClassName = XYZPage now had ClassName = '' after a /dev/build.

That prevented me from updating the page type in the behaviour tab in the CMS, as you described experiencing. Even when I had uploaded XYZPage.php to the dev server and run /dev/build again.

In order to not lose the widgets and extra content I had added to the page (which I would have by deleting it and creating a new page), updating the row manually in Sitetree so the ClassName = 'Page' seemed to do the trick - I was then able to update the page type from inside the CMS.