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.

Archive

Our old forums are still available as a read-only archive.

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

Tutorial Issues


Reply

8 Posts   2799 Views

Avatar
bilbo

8 May 2007 at 9:06am (Last edited: 8 May 2007 9:06am), Community Member, 10 Posts

Hello all-

Two issues:

First, I tried to follow Tutorial 2 instructions, but even after adding the pages, they don't show up as options when adding a new page in the administrator. Any ideas? I am using Linux, and did the flush command multiple times.

It may be that it isn't clear to me where to add the function "function getCMSFields() {...." in the ArticlePage class.

Second, I tried to download the tutorial files zip so that I can make sure I was following things correctly, but it gives me an error saying not a valid or a corrupted Zip file. I am using Windows XP with Winzip 9.0. Any ideas why I can't unzip them?

Thanks,

Marc

Avatar
Willr

8 May 2007 at 6:54pm Forum Moderator, 5511 Posts

Hey Marc,

Lets work though these good questions one by one.

1) Where to add the getCMS fields

- Add it in the class ArticlePage (or whatever your page is)

class ArticlePage extends Page {
// All your database stuff like $db

// Use the getCMSfields function here
}
class ArticlePage_Controller extends Page_Controller {

}
Maybe it doesn't make this very clear in the tutorial...

2) corrupted zip file

- Hmm I just tried and it worked for me. I used WinRAR though..

3) Pages not appearing

- have you done a /db/build/ not just a flush? try http://yoursite.com/db/build/?flush=1

Hope that helps

Avatar
Sean

8 May 2007 at 7:18pm (Last edited: 8 May 2007 7:20pm), Forum Moderator, 921 Posts

Good point, perhaps it's something we didn't make clear enough in the tutorials.

Whenever you add a new class like an ArticleHolder or ArticlePage, you need to add db/build?flush=1 at the end of the site's URL (just after adding them, allowing the database tables and fields to be created).

This is the prerequisite to being able to select your new page type within the SilverStripe CMS.

Cheers,
Sean

Avatar
bilbo

9 May 2007 at 5:03am (Last edited: 9 May 2007 5:38am), Community Member, 10 Posts

Thanks! I was just doing a flush, not a /db/?flush=1.

As for the tutorial files...once I extraced with a different extractor than WinZip I needed to rename the one extracted file to .zip, then I saw the files.

One other question:.

Can I create dates that are in the US format? mm/dd/yyyy...

Marc

Avatar
Sean

9 May 2007 at 10:07am Forum Moderator, 921 Posts

Currently you can't - $Date.Nice puts the date in DD/MM/YYYY (which is focused towards the way New Zealand usually formats the dates). If you leave it as $Date in your template it will format as YYYY/MM/DD instead.

In our internationalisation efforts in the next couple of months with Google summer of code we hope this is something which can be made more specific dependent on country.

Cheers!
Sean

Avatar
bilbo

10 May 2007 at 4:29am Community Member, 10 Posts

Great. Thanks. $Date.Long is a nice enough format.

Where can I find where the $Date modifiers (Long, Ago, etc.) are defined in the code? Maybe I can't see it...

Marc

Avatar
Willr

10 May 2007 at 4:02pm Forum Moderator, 5511 Posts

You can read about the Date Class here - http://doc.silverstripe.com/assets/classes/default/Date.html the actual code behind date is in this file - /sapphire/core/model/fieldtypes/Date.php

Avatar
kudesign

11 December 2008 at 9:43am (Last edited: 11 December 2008 10:03am), Community Member, 64 Posts

I am still having trouble with the ArticlePage.php (Adding the method to the ArticlePage class), this is my code:

<?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 db/build?flush=1 and multiple refreshes, it still does not show the Date and Author field when I tried to add a new ArticlePage in CMS. I'm on v2.2.3 What have I done wrong? Help!