Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Tutorial Issues

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

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

Page: 1
Go to End
Author Topic: 2744 Views
  • bilbo
    Avatar
    Community Member
    10 Posts

    Tutorial Issues Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Tutorial Issues Link to this post

    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

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Tutorial Issues Link to this post

    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

  • bilbo
    Avatar
    Community Member
    10 Posts

    Re: Tutorial Issues Link to this post

    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

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Tutorial Issues Link to this post

    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

  • bilbo
    Avatar
    Community Member
    10 Posts

    Re: Tutorial Issues Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Tutorial Issues Link to this post

    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

  • kudesign
    Avatar
    Community Member
    64 Posts

    Re: Tutorial Issues Link to this post

    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!

    2744 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.