Jump to:

7939 Posts in 1472 Topics by 944 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: 2349 Views
  • Martijn
    Avatar
    Community Member
    271 Posts

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

    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'));
          }   
       }

  • Webdoc
    Avatar
    Community Member
    329 Posts

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

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

  • Martijn
    Avatar
    Community Member
    271 Posts

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

    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.

  • Webdoc
    Avatar
    Community Member
    329 Posts

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

    ok tnx anyway

  • Webdoc
    Avatar
    Community Member
    329 Posts

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

    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)

  • Martijn
    Avatar
    Community Member
    271 Posts

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

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

  • Webdoc
    Avatar
    Community Member
    329 Posts

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

    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',
    ),

  • Webdoc
    Avatar
    Community Member
    329 Posts

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

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

    is this right??

    2349 Views
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.