Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Publish buttons dissapear just in one branch - and JS error

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

Page: 1
Go to End
Author Topic: 415 Views
  • KINKCreative
    Avatar
    Community Member
    56 Posts

    Publish buttons dissapear just in one branch - and JS error Link to this post

    Hi guys. I created a new pagetype... Nothing too complex, the class is below...

    I got called by a client today and a set of these VideoPages in a branch in the sitetree, about 3rd level down from the root, is not showing any Publish buttons. The VideoPages on any other section of the sitetree show the Publish button, but the button doesn't appear on any of these pages, all of them under a holder.

    When the client then pressed "Delete from Draft site" - the Save and Publish started to throw the "getAllFields() on a non-object"... error. No clue where that may be coming from?

    Any help on this would be greatly appreciated!!

    <?php

    class VideoPage extends Page {

        static $db = array(
          "YouTube" => "Varchar(255)"
        );

       static $has_one = array(
          "VideoThumbnail"=>"Image" //not used yet, I am therefore not adding the field
       );
       
       static $has_many = array(
       );
       
       static $defaults = array(
          "ProvideComments" => true
       );
       
       static $allowed_children = array();
       static $default_child = "";
       static $can_be_root = false;
       
       public function getCMSFields()
       {
          $f = parent::getCMSFields();
          $f->addFieldToTab("Root.Video", new TextField("YouTube","Enter YouTube link or video ID"));
          return $f;
       }
       
       public function LargeThumbnail() {
          if(!empty($this->YouTube)) {
             return "http://img.youtube.com/vi/$this->YouTube/0.jpg";
          }
       }
       
       public function IsNew() {
          $date1 = SS_Datetime::now()->Format('U');
          $date2 = strtotime($this->Created." +5 days");
          return $date2>$date1;
       }
       
       function canCreate($Member = null) {
        return true;
       }
       
       function canDelete($Member = null) {
        return true;
       }
       
       function canEdit($Member = null) {
        return true;
       }
       
       function canPublish($Member = null) {
        return true;
       }
       
       function onBeforeWrite() {
        if (preg_match('%(?:youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $this->YouTube, $match)) {
        $video_id = $match[1];
        $this->YouTube = $video_id;
        }
        parent::onBeforeWrite();
       }
       
    }

    class VideoPage_Controller extends Page_Controller {
          
       public function init() {
          parent::init();
       }
       
    }

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Publish buttons dissapear just in one branch - and JS error Link to this post

    So you might think the reason llies with the location in the sitetree... Just wondering: if you drag one of these (newly created) offending pages to a location on the sitetree where videopages live that behave properly, will the button now appear?

  • KINKCreative
    Avatar
    Community Member
    56 Posts

    Re: Publish buttons dissapear just in one branch - and JS error Link to this post

    The thing is I can't even drag and drop them. I did it, the sitetree visibly changed, but refreshing showed the old structure. A few of them had wrong titles and I couldn't save and publish them (as stated above). So I was able to pull a Batch action on them to remove them from the draft tree (the delete from draft button, though there, returned an error too), and had to add a new page with correct info and save that one.

    I wonder if there are any bugs when you are duplicating pages or pages with children, like something specific (class name?) is lost when you're duplicating... Something is pulling an empty site object and the fields are supposedly not there, that's what it seems to me. But I'm way too much in the dark here

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Publish buttons dissapear just in one branch - and JS error Link to this post

    I know of no bug in duplicating pages, have used it often - but of course that doesn't mean there isn't one.

    Weird that the batch delete worked where the delete button didn't... Anyway now they're all gone - and obviously you can create new one's on the same location, so that's fixed

    I'm curious if this will reproduce when the client starts to work on them again. In that case maybe you should create a databasedump first before removing - maybe something strange happened to the records that will set you on track...

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