21278 Posts in 5728 Topics by 2599 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 255 Views |
-
CMS Fields for a specific page

12 May 2012 at 5:14pm
Hello,
I'm new here, my name is Claudiu, guys, I have read lots of pages about how to add fields to cms, so far I try this code:
<?php
class Furniture extends Page {
public static $db = array(
'TestField'=> 'Text'
);public static $has_one = array(
);function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('TestField'), 'Content');
return $fields;
}
}class Furniture_Controller extends ContentController {}
?>
So I have this page called Furniture and I cant find a way to add that field to that page only, can anyone give me a hint how to do it, please?
Ciao,
Claudiu -
Re: CMS Fields for a specific page

12 May 2012 at 8:06pm
to get the field to web use in themes/yourtheme/layout/Furniture.ss
<div class="typography">
<% if Menu(2) %>
<% include SideBar %>
<div id="Content">
<% end_if %><% if Level(2) %>
<% include BreadCrumbs %>
<% end_if %>
<h2>$Title</h2>
$Content
<% if TestField %>
$TestField
<% end_if %>
$Form
$PageComments
<% if Menu(2) %>
</div>
<% end_if %>
</div> -
Re: CMS Fields for a specific page

12 May 2012 at 8:09pm
Thank you for your reply, I want to add fields to admin cms, like have custom field before or after the content for this furniture page.
Is there a way to do it ?Thank you,
Claudiu -
Re: CMS Fields for a specific page

12 May 2012 at 8:13pm
your field is added already. Did u use http://www.yoursitenane.com/dev/build?flush=1
do make it work -
Re: CMS Fields for a specific page

12 May 2012 at 8:21pm Last edited: 12 May 2012 8:24pm
Yes, but is not working, this is what I did for last 4 hours..
So I have this page FURNITURE uppercase, when I need to add fields into admin panel for this page, is the code I paste before I need to write something else?Because, I added same code to Page.php where the Page extends SiteTree and worked, but added that field to all pages and I need to only one to add some more fields.
Thank you,
Claudiu
| 255 Views | ||
|
Page:
1
|
Go to Top |


