Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Issues with TestimonialPage.ss & ResourcePage.ss

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 1207 Views
  • Roony
    Avatar
    Community Member
    14 Posts

    Issues with TestimonialPage.ss & ResourcePage.ss Link to this post

    If anyone can help me out with this dilema that would be appreciated.

    I have currently installed the dataobject module and also the swfupload successfully. I have followed the tutorial about ccreating a testimonials page to the dot, and also another one about creating an mp3/flv page on you tube.

    The CMS registers the testimonial page and the resources page and allows me to upload the correct file types.

    HOWEVER...

    When i go to view either of the pages they show up as white screens with nothing on them except the Title of the Page. I am at a loss and can not work out how to fix this?

    Any ideas?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Issues with TestimonialPage.ss & ResourcePage.ss Link to this post

    Probably a PHP syntax error of some sort. Crank up your error reporting.

  • Roony
    Avatar
    Community Member
    14 Posts

    Re: Issues with TestimonialPage.ss & ResourcePage.ss Link to this post

    I am unsure if there is any php coding errors but i followed the tutorial and copy pasted the code from there so I think it should be right. This is the code i am using at the moment!

    ~~~~~~~~~~~~~~~~~~~ Testimonials.php ~~~~~~~~~~~~~~~~~~~~~

    <?php

    class Testimonial extends DataObject
    {
       static $db = array (
          'Date' => 'Date',
          'Author' => 'Text',
          'Quote' => 'HTMLText'
       );
       
       static $has_one = array (
          'TestimonialPage' => 'TestimonialPage'
       );
          
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new CalendarDateField('Date'),
             new TextField('Author'),
             new TextareaField('Quote')
          );
       }
    }

    ?>

    ~~~~~~~~~~~~~~~~~~~ TestimonialsPage.php ~~~~~~~~~~~~~~~~~~~~~~~~~~

    <?php

    class TestimonialPage extends Page
    {
       static $has_many = array (
          'Testimonials' => 'Testimonial'
       );
       
       public function getCMSFields()
       {
          $f = parent::getCMSFields();
          $f->addFieldToTab("Root.Content.Testimonials", new DataObjectManager(
             $this,
             'Testimonials',
             'Testimonial',
             array('Date' => 'Date','Author'=>'Author','Quote' => 'Quote'),
             'getCMSFields_forPopup'
          ));
          return $f;
       }

    }

    class Testimonial_Controller extends Page_Controller {}

    ?>

  • UncleCheese
    Avatar
    4085 Posts

    Re: Issues with TestimonialPage.ss & ResourcePage.ss Link to this post

    If you're getting a white screen, you need to turn up your error reporting to find out what's going on. It's hard to troubleshoot an error that you can't see!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Issues with TestimonialPage.ss & ResourcePage.ss Link to this post

    Sorry, I missed one important thing. You said the title is rendering? Like it just says

    "TestimonialsPage"?

    If that's the case, you probably haven't created a controller for your page class.

  • Roony
    Avatar
    Community Member
    14 Posts

    Re: Issues with TestimonialPage.ss & ResourcePage.ss Link to this post

    How do I create a controller?

    Do I simply add <code> class Resource_Controller extends Page_Controller {} </code>

    And is that the same for the Resources.php and also the ResourcesPage.php or do i need to change it a bit?

    ie. <code> class ResourcePage_Controller extends Page_Controller {} </code>

    I have a fairly basic understanding of PHP coding so this is taking me a while.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Issues with TestimonialPage.ss & ResourcePage.ss Link to this post

    Yeah, it can be empty, like you have it, but your naming convention is wrong. Your controller is named TestimonialController, but it needs to match the model that it is controlling, which in your case is TestimonialPage. Controllers need to be named [ModelName]_Controller in order for the ModelAsController class to find the correct controller and template to use. So what you want is:

    class TestimonialPage_Controller extends Page_Controller {}

  • Roony
    Avatar
    Community Member
    14 Posts

    Re: Issues with TestimonialPage.ss & ResourcePage.ss Link to this post

    Does this need to be on both the TestimonialPage and the Testimonial php files?

    Or do I need to change them to reflect the page name ie:

    class TestimonialPage_Controller extends Page_Controller {}

    class Testimonial_Controller extends Page_Controller {}

    class ResourcePage_Controller extends Page_Controller {}

    class Resource_Controller extends Page_Controller {}

    When I added in the above to the php files i get an error

    XML Parsing Error: XML or text declaration not at start of entity
    Location: http://dev.cjtdesign.com.au/silverstripe-v2.3.4/resourcepage/
    Line Number 3, Column 1:<?xml version="1.0" encoding="UTF-8"?>
    ^

    1207 Views
Page: 1 2
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.