753 Posts in 310 Topics by 289 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1863 Views |
-
Widget on a new Page Type

21 February 2009 at 11:44am
Ok, so I was able to create a new page type with this instructions posted by Willr:
----------------------------
You can have widgets on any page type by adding a WidgetArea to it. Open the page type code and addstatic $has_one = array(
"MyWidgets" => "WidgetArea"
);then in the getCMSFields you will need to add the widget drag and drop system
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("MyWidgets"));
return $fields;
}Then last but not least you need to open up your template file and add the code to render the widget area. In this example you would need to put $MyWidgets in the template some where.
Remember to db/build and then flush the page.
----------I created a new HomePage.php, flushed the database and it loaded on the CMS... and it has the widget tab!
!
it took me a while to figure this out...
My problem now is that the pages I create with that page type print out the following:Error
The website server has not been able to respond to your request.I've been tryint to put the "$MyWidgets" to call the function on the page.ss of my template, also creating a new "HomePage.ss" but no luck...
Please Helpthx
-
Re: Widget on a new Page Type

27 March 2009 at 2:50pm
Okay, now seems like you have done everything good, but did you run a http://mysite.com/db/build?flush=1
if not try with that.
-
Re: Widget on a new Page Type

14 June 2009 at 3:20am
Hi , I've tried your method to add widget type but no success. The following is the code I've added to page.php.
public static $db = array(
);
public static $has_one = array(
);
static $has_one = array(
"MyWidgets" => "WidgetArea"
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("MyWidgets"));
return $fields;
}When I save the file to server I then cannot login or run db/build. I also added the field to page.ss just before the last /div.
I am a complete newbie to PHP and SS so I probably have screwed up the code somewhere. Any help appreciated.
GK
| 1863 Views | ||
|
Page:
1
|
Go to Top |



