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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Adding new page type breakes cms


Go to End


1855 Views

Avatar
baniakjr

Community Member, 4 Posts

6 December 2010 at 11:56pm

Edited: 07/12/2010 9:35am

Hi,

I have a problem, when I'm adding page type that is presented below it breaks the cms. Page tab in the cms displays improperly and pop-ups opens in the same page instead of poping up. I've set up fresh installation and added only this page type same thing happens. There are no other negativ effects, everything works fine, the code works fine, all other tabs in cms wroks fine too. I'm attaching screen shot of broken cms, it does not display on full screen and is a bit wrong.

My code is base on event_calendar and event_calendar_register.

Can any one help me.

EDIT: I experimented a bit and found out that this problem occurec only when i have two files together when any one of them is alone every thing is ok. When I put them both into mysite/code/ cms breakes. In addition to bad visual of cms whenever i open pop up field i get message "The action 'admin' does not exist in class CMSMain".

I tried simple stuff like changing they're name. It also appears that whenever ArticleHolder is present and i create even empty class extending calendar the saem thing happens

class MeetingHolder extends Calendar
 {
 static $has_many = array (
 'Meetings' => 'Meeting'
 );
 
 static $allowed_children = array (
 'Meeting'
 );
 }

 class MeetingHolder_Controller extends Calendar_Controller
 {
	static $allowed_actions = array (
		'register',
		'SignUpForm'
	);

	public function register(SS_HTTPRequest $request) {
		if(!$request->requestVar('DateID') && !$request->requestVar('g')) {
			return Director::redirectBack();
		}
		return array();
	}

        public function getGender() {
		$g = $this->getRequest()->requestVar('g');
		if( $g=='k') {
			return 'Kobieta';
        	}
		if( $g=='m') {
			return 'Mężczyzna';
		}
		else {
			return '';
		}
        }

        public function getDates() {
		$date_id = (int) $this->getRequest()->requestVar('DateID');
		if(!$date = DataObject::get_by_id("MeetingDateTime", $date_id)) {
			return '';
		}
		return $date->_Dates();
        }

	        public function getTimes() {
		$date_id = (int) $this->getRequest()->requestVar('DateID');
		if(!$date = DataObject::get_by_id("MeetingDateTime", $date_id)) {
			return '';
		}
		return $date->_Times();
        }

	        public function getTitle() {
		$date_id = (int) $this->getRequest()->requestVar('DateID');
		if(!$date = DataObject::get_by_id("MeetingDateTime", $date_id)) {
			return '';
		}
		return $date->Meeting()->Title;
        }

	function SignUpForm() {
	$date_id = (int) $this->getRequest()->requestVar('DateID');
	$g = $this->getRequest()->requestVar('g');
	if(!$date = DataObject::get_by_id("MeetingDateTime", $date_id)) {
		return $this->httpError(404);
	}
        $dhf = new HiddenField ("date_id","date_id","$date_id");
        if( $g!='k' && $g!='m') {
		return $this->httpError(404);
        }
	if( $g=='k') {
		$hf = new HiddenField ("gender","gender","K");
        } else {
		$hf = new HiddenField ("gender","gender","M");
        }

         $fields = new FieldSet(
         new TextField('name','Imię'),
	 new TextField('surname','Nazwisko'),
         $hf,
	 $dhf
      );
 
      $actions = new FieldSet(
         new FormAction('doSignUp', 'Submit')
      );
 
      return new Form($this, 'SignUpForm', $fields, $actions);
   }


   function doSignUp($data, $form) {
   $submission = new SignUpSubmission();
   $form->saveInto($submission);
   $date = DataObject::get_by_id("MeetingDateTime", (int) $this->ID);
   $submission->Meeting=$date;

	$email = new Email('address@a.com', 'address@a.com', 'Zgłoszenie', $submission->toString());
	$email->send();
 
      Director::redirectBack();
   }
 }

class ArticleHolder extends Page {
   static $db = array(
   );
   static $has_one = array(
   );
 
   static $allowed_children = array('ArticlePage');


 function getCMSFields() {
$fields = parent::getCMSFields(); 
$fields->removeFieldFromTab("Root.Content.Main","Content");
      return $fields;
}

}
 
class ArticleHolder_Controller extends Page_Controller {
function NewsArticles() {
  if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
  $SQL_start = (int)$_GET['start'];
  $doSet = DataObject::get(
    $callerClass = "ArticlePage",
    $filter = "`ParentID` = '".$this->ID."'",
    $sort = "Date DESC",
    $join = "",
    $limit = "{$SQL_start},5"
  );
 
  return $doSet ? $doSet : false;
}

function rss() {
  $rss = new RSSFeed($this->Children(), $this->Link(), "Aktualności Speed Dating Katowice");
  $rss->outputToBrowser();
}

function init() {
   RSSFeed::linkToFeed($this->Link() . "rss");	
   parent::init();
}
 
}

Attached Files