Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

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

Go to End

27 Posts   3802 Views


Community Member, 349 Posts

18 September 2010 at 8:15am

gives error something is wrong


Community Member, 103 Posts

21 September 2010 at 2:18am

Edited: 21/09/2010 2:19am

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!


Community Member, 349 Posts

22 September 2010 at 9:05am

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

Go to Top