5116 Posts in 1525 Topics by 1118 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1316 Views |
-
Tutorial 2 problem

14 January 2009 at 6:20am
Experts:
I am certain this has been discussed before, but I can not find it here. I am just getting started with SS
and so far Tutorial 1 has been great. Now I get to #2 and things become fuzzy.
Running on a site on GoDaddy, so all is pre-installed.It is not very clear as to where to place the function getCMSFields in the ArticlePage.php code.
I have placed it like this:
<?php
/**
* Defines the ArticlePage page type
*/
class ArticlePage extends Page {
static $db = array(
'Date' => 'Date',
'Author' => 'Text'
);
static $has_one = array(
);function getCMSFields() {
$fields = parent::getCMSFields();$fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
return $fields;}
class ArticlePage_Controller extends Page_Controller {
}
After which I flush and rebuild the db
http://xxx.com/silverstripe/db/build?flush=1
After which in the rebuild output I see:
Parse error: syntax error, unexpected T_CLASS, expecting T_FUNCTION
Can one of you experts on SS direct me in the right direction please?
Trying to come up to speed with this and it seems to be a battle to undertand
how this works in comparison to the build the code by hand method.Thanks so much!
DB_steve -
Re: Tutorial 2 problem

14 January 2009 at 6:48am Last edited: 14 January 2009 6:49am
Don't know if you just did a typo, but there is a missing '}' that should end the ArticlePage class.
So add a } on the line aboveclass ArticlePage_Controller extends Page_Controller {
and it will hopefully work.
-
Re: Tutorial 2 problem

14 January 2009 at 6:58am
Thanks for looking the code over, however the } is there
just did not get it when I copied the code over to here for posting.Now here is what I have discovered.
If I save this code and do not rebuild the database AND just refresh the CMS
then create the articleholder page named "news" this works.
Then create the articlepages insode "news" and this works.Now that this has been accomplished, now rebuild the DB and all is ok, no errors
and the items show up in the draft site as expected.Just have to get the flow right, which is not very clear at all in the tutorial.
db_steve
<?php
/**
* Defines the ArticlePage page type
*/
class ArticlePage extends Page {
static $db = array(
'Date' => 'Date',
'Author' => 'Text'
);
static $has_one = array(
);function getCMSFields() {
$fields = parent::getCMSFields();$fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
return $fields;
}}
class ArticlePage_Controller extends Page_Controller {
}
?>
-
Re: Tutorial 2 problem

14 January 2009 at 5:14pm
db_steve - if it helps to clear it up, you need to run db/build?flush=1 (renamed dev/build in version 2.3) whenever you modify anything to do with the database (adding new PHP files, adding new entrys to $db or $has_one etc). dev/build keeps your database and environment up to date
Whenever you edit anything else (edit templates or add fields to a page) you should always refresh the page or cms with ?flush=1 just to make sure
| 1316 Views | ||
|
Page:
1
|
Go to Top |


