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

New fields in content not getting added


Reply


4 Posts   1908 Views

Avatar
Decisive Flow

Community Member, 73 Posts

15 November 2006 at 2:55pm

Edited: 15/11/2006 3:06pm

I've created a little 'blurb' text area for a page type, when I flush the database, it appears to create the field, but it never shows up in the back end. On another site, it's working fine, and I can't think of why it's not here.

I have:
1) added this code (below)
2) flushed database
3) assigned new page type to content items

UPDATE: I've just pulled the code over to another page type and it works fine. Just not in the new one...

PS. Do I get a gold star for asking the most questions? :)

class TeamMember extends Page {
   
static $db = array(
      "IntroductionText" => "Text",
      "Blurb" => "Text",
   );
}

function getCMSFields() {
      $fields = parent::getCMSFields();
      
      $fields->addFieldToTab("Root.Content.Main", new TextareaField("IntroductionText", "Short Blurb"), "Content");
      $fields->addFieldToTab("Root.Content.Main", new TextareaField("Blurb", "Blurb"), "Content");

      return $fields;
   }   

class TeamMember_Controller extends Page_Controller {
}

?>

Avatar
Simon

Core Development Team, 27 Posts

15 November 2006 at 3:06pm

Edited: 15/11/2006 3:07pm

If thats a direct copy of your code, you'll need to move the function getCMSFields() into the class for it to do anything :-)

(I think its just a misplaced squigly bracket)

IE:

class TeamMember extends Page {

static $db = array(
"IntroductionText" => "Text",
"Blurb" => "Text",
);
function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab("Root.Content.Main", new TextareaField("IntroductionText", "Short Blurb"), "Content");
$fields->addFieldToTab("Root.Content.Main", new TextareaField("Blurb", "Blurb"), "Content");

return $fields;
}

}

We should run a competition or something for the person that discovers the most bugs :-p

Avatar
Decisive Flow

Community Member, 73 Posts

15 November 2006 at 3:11pm

eh, stupid }'s ;) thanks, fixed now.

Man, nothing like a little PHP to make you feel braindead.

I'm in for the bug finding, though I believe I am more of a bug creator, all things ocnsidered ;)

Avatar
Sean

Forum Moderator, 922 Posts

15 November 2006 at 3:27pm

I'm sure we could create a ranking board for forum members who ask the most questions. I think you're #1 at the moment anyways. ;)

Cheers,
Sean