Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Generated with the default ContentController.ss template

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

Page: 1 2 3
Go to End
Author Topic: 7140 Views
  • clintonf
    Avatar
    Community Member
    8 Posts

    Re: Generated with the default ContentController.ss template Link to this post

    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

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Generated with the default ContentController.ss template Link to this post

    "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.

  • stevanovich
    Avatar
    Community Member
    59 Posts

    Re: Generated with the default ContentController.ss template Link to this post

    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.

  • wildflower1975
    Avatar
    Community Member
    59 Posts

    Re: Generated with the default ContentController.ss template Link to this post

    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

  • martimiz
    Avatar
    Forum Moderator
    1037 Posts

    Re: Generated with the default ContentController.ss template Link to this post

    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();
    }
    }

  • arthurdent
    Avatar
    Community Member
    132 Posts

    Re: Generated with the default ContentController.ss template Link to this post

    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?

  • arthurdent
    Avatar
    Community Member
    132 Posts

    Re: Generated with the default ContentController.ss template Link to this post

    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...

  • dizzystuff
    Avatar
    Community Member
    93 Posts

    Re: Generated with the default ContentController.ss template Link to this post

    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.

    7140 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.