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

Job Portal from book not working in SS 3.0.3


Go to End


4 Posts   994 Views

Avatar
mivilleb

Community Member, 3 Posts

2 January 2013 at 11:58am

I am using SS 3.0.3 on Ubuntu with Apache2 and Php 5.3

I only copied the Job php files from the Wiley site:

http://au.wiley.com/WileyCDA/WileyTitle/productCd-0470681837,descCd-DOWNLOAD.html

Job.php
JobCategory.php
JobCategoryHolder.php

to:

mysite/code

and the ss files to:

JobCategory.ss
JobCategoryHolder.ss
JobCategory_showjob.ss

themes/simple/templates/Layout

Then ran the dev/build

index.php/dev/build

and it worked without any errors, created the tables etc.

I created a main Job page and assign it a "Job Category Overview" type and that worked.

I created 2 pages under the Job page and tried assigning them with the "Job Category" type but it just returns a blank page after I click on Save and Publish. From that point on, non of the Admin menu works and all returning blank page. If I refresh the admin page everything returns to normal but the sub pages have not been assigned the new type.

No errors in the Apache2 logs.

Any idea what is going on?

Avatar
mivilleb

Community Member, 3 Posts

2 January 2013 at 3:20pm

I re-installed SS3, just in case it was screwed up, took the Job files from the book, modified them to fit my needs and the error I get is the following:

Error at line 1043 of SS3/framework/model/DataObject.php

after I do a dev/build (no errors) and try to assign a new type to a page.

Attached are the 3 php files I am using (had to rename to .txt for the upload to work).

Any idea?

Attached Files
Avatar
mivilleb

Community Member, 3 Posts

2 January 2013 at 3:52pm

Doing the 3.0 tutorial here:

http://doc.silverstripe.org/framework/en/tutorials/5-dataobject-relationship-management

I get the same error as above:

Error at line 1043 of SS3/framework/model/DataObject.php

when I try to assign a Project type to a page.

Is there a bug in SS3 or am I doing it wrong?

Avatar
zenmonkey

Community Member, 545 Posts

8 January 2013 at 5:23pm

There is a lot of legacy code in that if you're working in 3. Try updating the reuests and replacing the ComplexTable field with a GridField to start. Also put the site into devmode to get better error reporting. I suspect in the backend the ComplexTable field ma be a problem but ActiveTenders function should be updated to a SS3 compatible query. Now I'm not sure if you can query for nulls and functions with a raw SQL where() in SS3 but you could request the whoel DataList and filter it like

public function ActiveTenders() {
	$ActiveTenders = new ArrayList();
	foreach($this->Tenders() as $tender) {
		if(is_null($tender->ExpiryDate) || strtotime($tender->ExpiryDate) > time()) {
			$ActiveTenders->push($tender);
		}
	}
	return $ActiveTenders;
}

I find some simple operations more complex with the new ORM, but the flexabilty and chainability is worth it.
http://doc.silverstripe.org/framework/en/topics/datamodel

As for the GridField

$tenderManagerConfig = GridFieldConfig_RelationEditor::create();
$tenderManagerConfig->addComponents(
	new GridFieldDetailForm('Tender')
);
$tenderManager = new GridField(
	"Tenders", "Tenders",
	$this->Tenders(), 
	$tenderManagerConfig
);
$fields->addFieldToTab('Root.Main', $tenderManager);