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.

Archive /

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

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

Tutorial Issues


Go to End


8 Posts   3923 Views

Avatar
bilbo

Community Member, 10 Posts

8 May 2007 at 9:06am

Edited: 08/05/2007 9:06am

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

Forum Moderator, 5523 Posts

8 May 2007 at 6:54pm

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

Forum Moderator, 922 Posts

8 May 2007 at 7:18pm

Edited: 08/05/2007 7:20pm

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

Community Member, 10 Posts

9 May 2007 at 5:03am

Edited: 09/05/2007 5:38am

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

Forum Moderator, 922 Posts

9 May 2007 at 10:07am

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

Community Member, 10 Posts

10 May 2007 at 4:29am

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

Forum Moderator, 5523 Posts

10 May 2007 at 4:02pm

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

Community Member, 64 Posts

11 December 2008 at 9:43am

Edited: 11/12/2008 10:03am

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!