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, biapar, Willr, Ingo, swaiba, simon_w

Need help to show dataobject on page


Reply

27 Posts   2726 Views

Avatar
Martijn

14 September 2010 at 6:31am Community Member, 271 Posts

For a single object :

http://www.vspalvelut.fi/katsetus/korterid/show/1

You might want to try this for your controller:

/**
    * In template
    * <% if Objekt %>
    * <% control Objekt %>
    * $Objektinimi
    * $Kirjeldus
    * <% end_control %>
    * <% end_if %>
    *
    */
   function show(){
      return array();
   }
   
   function Objekt(){
      if(isset($this->request) && $this->request->param('ID')){
         return DataObject::get_by_id('Objekt', (int)$this->request->param('ID'));
      }   
   }

Avatar
Webdoc

14 September 2010 at 6:41am Community Member, 332 Posts

can u try the code and send me back if u get work seem i need to blonde my hair :P

Avatar
Martijn

14 September 2010 at 6:57am Community Member, 271 Posts

Sorry, I'm not gonna code it for you and I can't explain it easier then I did....

Please take some time for the tutorials I posted earlier. You will gather much more knowledge from it and will write better code in the end...

Also make sure you read this to debug you website:

http://doc.silverstripe.org/debugging

And fresh from the press:

http://www.leftandmain.com/silverstripe-tips/2010/09/08/8-common-silverstripe-errors-explained-and-solved/

Hope this helps.

Avatar
Webdoc

14 September 2010 at 6:59am Community Member, 332 Posts

ok tnx anyway

Avatar
Webdoc

18 September 2010 at 5:31am (Last edited: 18 September 2010 5:35am), Community Member, 332 Posts

is there a way to add in function:

/**
* In template
* <% if Objekt %>
* <% control Objekt %>
* $Objektinimi
* $Kirjeldus
* <% end_control %>
* <% end_if %>
*
*/
function show(){
return array();
}

function Objekt(){
if(isset($this->request) && $this->request->param('ID')){
return DataObject::get_by_id('Objekt', (int)$this->request->param('ID'));
}
}

the theme .ss file what the objekt.ss dataobject uses

so that if i use nimekiri i use nimiekiri.ss and if i wanna see the more info about the dataobjects listed on nimekiri.ss i use the theme named objekt.ss

in this function it shows the same in mysite.com/nimekiri/ and mysite.com/nimekiri/show/1 (for the last i wanna use the objekt.ss template)

Avatar
Martijn

18 September 2010 at 5:51am Community Member, 271 Posts

Use Nimekiri_show.ss to use that template for the show Action.

Avatar
Webdoc

18 September 2010 at 7:04am Community Member, 332 Posts

one more question
in searchable fields in objekt.php
what i need to add in my language file and this part of file to translate the search field

static $searchable_fields = array(
'Elamutyyp' => array(
'title' => 'the translation code',
'filter' => 'ExactMatchFilter',
),

Avatar
Webdoc

18 September 2010 at 7:50am Community Member, 332 Posts

static $searchable_fields = array(
'Elamutyyp' => array(
'title' => 'sprintf(_t('ClassName.ELAMU',"Elamut&uuml;&uuml;p")),$title)',
'filter' => 'ExactMatchFilter',
),

is this right??