gives error something is wrong
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
DataObjectManager Module /
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba
Need help to show dataobject on page
- Previous 10 entries
- 1
- 2
- 3
- Page 44(current)
I am having some trouble with this too. I'm guessing that Webdoc is also using these tutorials...
http://www.ssbits.com/using-silverstripe-url-parameters-to-display-dataobjects-on-a-page/
http://www.ssbits.com/display-dataobjects-in-an-seo-friendly-way/
I looked at the comment made on the 2nd linked page about using the SEO friendly version on 2.4 but I'm not understanding exactly how this additional code fits in to the entire implementation.
Here is my code thus far:
UsedEquip.php
class UsedEquip extends DataObject{
static $db = array (
'Name' => 'Text',
'Description' => 'Text',
'Material' => "Enum('Mild Steel,Stainless Steel','Mild Steel')",
'Tanks' => 'Text',
'MaterialHandling' => "Enum('Conveyor,Drum,Monorail','Conveyor')",
'URLSegment' => 'Varchar(255)'
);
static $has_one = array (
'UsedEquipPage' => 'UsedEquipPage',
'Photo' => 'Image'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name','Name'),
new SimpleHTMLEditorField('Description'),
new DropdownField(
$name = "Material",
$title = "Made From",
$source = singleton('UsedEquip')->dbObject('Material')->enumValues()
),
new TextField('Tanks','No. of Tanks'),
new DropdownField(
$name = "MaterialHandling",
$title = "Material Handling",
$source = singleton('UsedEquip')->dbObject('MaterialHandling')->enumValues()
),
new ImageField('Photo')
);
}
function Thumbnail() {
$Photo = $this->Photo();
if ( $Photo ) {
return $Photo->CMSThumbnail();
} else {
return null;
}
}
//This function doesnt work with the Name property defined as Varchar--I changed it to Text, but now URLSegments are always
//numbers
public function onBeforeWrite(){
if($this->Name){
$this->URLSegment = SiteTree::GenerateURLSegment($this->Name);
if($object = DataObject::get_one($this->ClassName, "URLSegment='" .$this->URLSegment
."' AND ID !=".$this->ID)){
$this->URLSegment = $this->URLSegment.'-'.$this->ID;
}
else {
$this->URLSegment = SiteTree::GenerateURLSegment($this->ClassnName.'-'.$this->ID);
}
parent::onBeforeWrite();
}
}
}
class UsedEquip_Controller extends Controller{
}
UsedEquipPage.phpclass UsedEquipPage extends Page{
static $has_many = array (
'UsedEquips' => 'UsedEquip'
);
public function getCMSFields()
{
$fields = parent::getCMSFields();
$manager = new DataObjectManager(
$this, // Controller
'UsedEquips', // Source name
'UsedEquip', // Source class
array(
'Name' => 'Name',
'Description' => 'Description',
'Material' => 'Material',
'Tanks' => 'Tanks',
'MaterialHandling' => 'MaterialHandling',
'Thumbnail' => 'Photo',
'URLSegment' => 'URLSegment'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$fields->addFieldToTab("Root.Content.Equipment",$manager);
return $fields;
}
}
class UsedEquipPage_Controller extends Page_Controller{
function init(){
Requirements::javascript("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js");
if(Director::is_ajax() /*|| $_GET["ajaxDebug"]*/) {
$this->isAjax = true;
}
else{
$this->isAjax = false;
}
parent::init();
}
public function getIndividualEquip(){
if($URLAction = Director::URLParam('Action')){
$EquipURLSegment = Convert::raw2xml($URLAction);
if($EquipURLSegment){
return DataObject::get_one('UsedEquip',"URLSegment='".$EquipURLSegment."'");
}
}
}
}
Any Help much appreciated!
enum cant be translated but i made it myself easier just added the enums like so:
'Elamutyyp' => "Enum('Korter, Maja, Aripind, Suvila, Ridaelamu, Paarismaja, Maatykk, Kerrostalo_osake, Omakotitalo, Liiketila, Kesamokki, Rivitalo, Paritalo, Tontti')",
here are both estonian and finnish language and in template for search used:
$form->disableSecurityToken();
so i was able to made my own costum search without needing securityID
- Previous 10 entries
- 1
- 2
- 3
- Page 44(current)