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.

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


Go to End


27 Posts   4505 Views

Avatar
Martijn

Community Member, 271 Posts

14 September 2010 at 6:31am

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

Community Member, 349 Posts

14 September 2010 at 6:41am

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

Avatar
Martijn

Community Member, 271 Posts

14 September 2010 at 6:57am

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

Community Member, 349 Posts

14 September 2010 at 6:59am

ok tnx anyway

Avatar
Webdoc

Community Member, 349 Posts

18 September 2010 at 5:31am

Edited: 18/09/2010 5:35am

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

Community Member, 271 Posts

18 September 2010 at 5:51am

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

Avatar
Webdoc

Community Member, 349 Posts

18 September 2010 at 7:04am

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

Community Member, 349 Posts

18 September 2010 at 7:50am

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

is this right??