Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Need help to show dataobject on page

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3 4
Go to End
Author Topic: 2659 Views
  • Webdoc
    Community Member
    332 Posts

    Re: Need help to show dataobject on page Link to this post

    gives error something is wrong

  • theoldlr
    Community Member
    103 Posts

    Re: Need help to show dataobject on page Link to this post

    I am having some trouble with this too. I'm guessing that Webdoc is also using these tutorials...


    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:


    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
    public function onBeforeWrite(){
    $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);


    class UsedEquip_Controller extends Controller{


    class 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
    '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

    return $fields;


    class UsedEquipPage_Controller extends Page_Controller{
    function init(){
    if(Director::is_ajax() /*|| $_GET["ajaxDebug"]*/) {
    $this->isAjax = true;
    $this->isAjax = false;

    public function getIndividualEquip(){
    if($URLAction = Director::URLParam('Action')){
    $EquipURLSegment = Convert::raw2xml($URLAction);
    return DataObject::get_one('UsedEquip',"URLSegment='".$EquipURLSegment."'");


    Any Help much appreciated!

  • Webdoc
    Community Member
    332 Posts

    Re: Need help to show dataobject on page Link to this post

    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:


    so i was able to made my own costum search without needing securityID

Page: 1 2 3 4
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.