762 Posts in 312 Topics by 291 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 566 Views |
-
PageContentWidget help needed ss3

5 October 2012 at 2:55am Last edited: 11 October 2012 5:21am
Has anyone allready got PageContentWidget working on ss3.2?
The widget installs ok but when you add the widget to the page youll get an error. it does not give further info!
I found the problem should be somewhere in the dropdownfield but dont know in ss3 how to solve this! Been looking in docs for ages.. but found no good descriptions how to call a sitetree for selection.Get error 568 in framework/model/MySQLdatabase.php
<?php
class PageContentWidget extends Widget {
static $db = array(
"WidgetTitle" => "Varchar(255)",
"PageID" => "Int"
);
static $defaults = array(
"WidgetTitle" => 'Page Content',
"PageID" => 0
);
static $title = "";
static $cmsTitle = "Pagina inhoud tonen in de zijbalk";
static $description = "Laat een pagina in de zijbalk zien van max 140px breed.";
function getCMSFields() {
$obj = 'SiteTree';
$filter = "Status = 'Published'";
//adding Sort != 0 will typically remove Blog Posts and Forum Topics (can be buggy)
//$filter = "Status = 'Published AND Sort != 0'";
$sort = 'Title ASC';
$join = '';
$limit = '';
$records = DataObject::get($obj, $filter, $sort, $join, $limit);$dropDownArray = array();
if($records->exists()) foreach( $records as $record ) {
$dropDownArray[$record->ID] = $record->Title;
}return new FieldSet(
new TextField("WidgetTitle", "Type de titel welke bovenaan in de kop moet komen"),
new TreeDropdownField(
$name = "PageID",
$title = "Kies de pagina welke je in de zijbalk wilt tonen:",
$source = $dropDownArray
)
);
}function output() {
$obj = 'SiteTree';
$id = $this->PageID;
$record = DataObject::get_by_id($obj,$id);
return $record->Content;
}
}How can i solve this problem so the widget works?
-
Re: PageContentWidget help needed ss3

17 October 2012 at 7:31am Last edited: 17 October 2012 7:33am
dont know if im on the right way... but got anothe error but now from the widgets module
function getCMSFields() {
$obj = 'SiteTree';
$filter = "Status = 'Published'";
$sort = 'Title ASC';
$join = '';
$limit = '';
$records = DataObject::get($obj, $filter, $sort, $join, $limit);
}public function AllPages() {
$gridField = new GridField('pages', 'All pages', SiteTree::get(), GridFieldConfig_RecordViewer::create());
return new Form($this, "AllPages", new FieldList($gridField), new FieldList());
}function output() {
$obj = 'SiteTree';
$id = $this->PageID;
$record = DataObject::get_by_id($obj,$id);
return $record->Content;
}
------------------------------------------------------
Hope this way with gridfield the page selected in the fieldlistdropdown? would be saved?
------------------------------------------------------the only thing now is i get from the module widgets an error:
Warning at line 163 widgets/code/model/Widget.php
wich is:public function CMSEditor() {
$fields = $this->getCMSFields();
$outputFields = new FieldList();
foreach($fields as $field) {
$name = $field->getName();
$value = $this->getField($name);
if ($value) {
$field->setValue($value);
}
$name = preg_replace("/([A-Za-z0-9\-_]+)/", "Widget[" . $this->ID . "][\\1]", $name);
$field->setName($name);
$outputFields->push($field);
}
return $outputFields;
}------------------------------------------------------------
Does anyone know how to solve this?
| 566 Views | ||
|
Page:
1
|
Go to Top |
