17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2271 Views |
-
New Page Types and Default Page Type

31 July 2007 at 8:45pm Last edited: 31 July 2007 10:43pm
Hello,
Is there a way to replace the field types inherited on new Page TYypes from the default Page Type?
What do I mean by this? On each page, the author must enter 'Page name', 'Navigation label' and 'Content'. I would like to create a field called 'Description' and have this field populate the entered value into the 'Page name', 'Navigation label' fields as well.
In addition, must we have the 'Content' field? Can we change the associated label?
I am just playing about with the backend at the moment for a project we are working on.
Kind regards,
Gary
-
Re: New Page Types and Default Page Type

31 July 2007 at 9:32pm Last edited: 31 July 2007 9:38pm
As far as I know, the only way to easily do this is by removing the Title, Content and MenuTitle fields and then re-adding the appropriate ones.
For example:
class MyPage extends Page {
function getCMSFields() {
$fields = parent::getCMSFields();// remove these fields
$fields->removeByName('Title');
$fields->removeByName('Content');// re-add the fields, with a different title
$fields->addFieldToTab('Title', 'My new title');
$fields->addFieldToTab('Content', 'My Content');return $fields;
}}
Hope this helps!
Sean
-
Re: New Page Types and Default Page Type

1 August 2007 at 9:58am
Thanks Sean!
Do you know if there is a way to populate those fields automatically? Often, each will have the same value and it seems a shame to make the user enter them three times (I do know that they each are used in a different way).
Cheers,
Gary
-
Re: New Page Types and Default Page Type

1 August 2007 at 2:00pm
Which fields would you automatically populate, and from what field(s)?
Cheers,
Sean -
Re: New Page Types and Default Page Type

1 August 2007 at 2:48pm
Hi Sean,
I had been thinking of adding a field called Description on a new table. By default, all tables include 'Page name' and 'Navigation label'. I had though of removing 'Page name' and 'Navigation label' when adding a new record to this table and having the value of the 'Description' field added to these two fields when the record is saved.
Does this make sense?
Cheers,
Gary
-
Re: New Page Types and Default Page Type

1 August 2007 at 3:19pm Last edited: 1 August 2007 3:19pm
I think you can do this in the page's onBeforeWrite() method.
Try something like:
protected function onBeforeWrite() {
$this->Title = $this->Description;
$this->menuTitle = $this->Description;parent::onBeforeWrite();
}Although I'm not actually sure if onBeforeWrite happens before of after $this->Description is set, now I think of it...
-
Re: New Page Types and Default Page Type

2 August 2007 at 9:06am
Thanks Nathan, I'll have a look at this.
| 2271 Views | ||
|
Page:
1
|
Go to Top |



