Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » getCMSFields problem

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

Page: 1
Go to End
Author Topic: 1095 Views
  • Mediaversa
    Avatar
    Community Member
    5 Posts

    getCMSFields problem Link to this post

    Hello everyone,

    I'm working on a website with silverstripe, and I'm running into a problem. I'm trying to add a new tab with 2 fields on multiple pagetypes (like 20), and on 6 of them, the fields are not added after flushing. The stupid thing is that the pages are 99% equal to eachother, except for the fieldnames.

    It there something that can prevent silverstripe from adding the fields to the cms when flushing?

    The code I've used:

    class HistoriePage extends SiteTree
    {
       static $db = array(
       'BlauwKopHistorie' => 'Varchar(100)',
       'BlauwContentHistorie' => 'Varchar(255)',
       );
       
       function getCMSFields()
       {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab("Root.Content.BlauwVeld", new TextField('BlauwKopHistorie', 'Koptekst'));
          $fields->addFieldToTab("Root.Content.BlauwVeld", new TextField('BlauwContentHistorie', 'Inhoud'));
          return $fields;
       }
       
       public static $has_one = array(
       );
    }

    class HistoriePage_Controller extends ContentController
    {   
       public function init() {
          parent::init();

          // Note: you should use SS template require tags inside your templates
          // instead of putting Requirements calls here. However these are
          // included so that our older themes still work
          // Requirements::themedCSS("layout");
          // Requirements::themedCSS("typography");
          // Requirements::themedCSS("form");
          i18n::set_locale('nl_NL');
       }
    }

    Thanks in advance,
    Xander

  • Willr
    Avatar
    Forum Moderator
    5502 Posts

    Re: getCMSFields problem Link to this post

    As an aside, is there any reason why you are extending SiteTree rather than extending your base class 'Page.php'. On the 6 pages which aren't showing the fields are they of the correct page type 'HistoriePage'. What does the dropdown say on the Behaviour tab on one of those 6 pages.

  • Mediaversa
    Avatar
    Community Member
    5 Posts

    Re: getCMSFields problem Link to this post

    The reason I expended it on SiteTree rather then Page, is because I've used "Page" as my homepage, and added some fields to to that one which are only needed on the homepage.

    The point is, it's not 1 pagetype I'm using. The website I'm working on, does have different templates all over the page, which makes me need to create different templates for every page. I need to add these 2 fields mentioned before on every of these pages. I've done that by creating the fields on one of the pagetypes, testing it, and then duplicated them to all the other pagetypes. Ofcourse I've changed the fieldnames in every template, As I know that duplicated fields are not allowed. It worked out for most of the templates, but 6 of them don't. The most annoying thing is that if I compare the .php files of the pagetypes with eachother, only the fieldnames are different. I have no clue why the rest won't work:/. When using the dev/build option, the fields are just not getting added. Nothing happens at all, however when I add more fields on one of the pages that does work, they are added without any problems....

    1095 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.