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

How to call action from dataobject


Go to End


16 Posts   3029 Views

Avatar
Webdoc

Community Member, 349 Posts

20 November 2010 at 4:13am

Edited: 20/11/2010 4:29am

do i need to use those fields what i wanna show in that like picture and price. but anyways this code dont show in web also the categorie names aint visible in that page.

do i use it like this then:
<% control Categories %>
$CategoryName
<% control Bikes %>
<div class="pilt">
<table width="220" border="0" cellspacing="0" cellpadding="0" style="height:170; vertical-align:top; text-align:center;">
<tr>
<td height="19"><div style="text-align:center;"><strong><a href="$link" title="$Mootorrattanimi">$Mootorrattanimi</a><strong></div></td>
</tr>
<tr>
<td height="150" valign="top"><div style="text-align:center;"><a href="$link" title="$Mootorrattanimi">$Photo.Setheight(143)</a></div></td>
</tr>
</table>
</div>
<% end_control %>
<% end_control %>

Avatar
Webdoc

Community Member, 349 Posts

20 November 2010 at 4:47am

Edited: 20/11/2010 4:49am

Something is wrong with the function because everything else shows up the fields and stuff. Only when the fields are inside categories controller they dont show up so something is wrong with the controller code with categories.
Also categorie names dont show up

Avatar
UncleCheese

Forum Moderator, 4102 Posts

20 November 2010 at 5:30am

Your Categories() function doesn't return anything!!

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
Webdoc

Community Member, 349 Posts

20 November 2010 at 5:35am

Edited: 20/11/2010 5:42am

its shows categories in backend but not in frontend

nothing , nada, ничего.

if <% control Bikes %> is before categories its shows the bike info but not category if its after categories its doesnt show anything. thats why i thing the function is broken.

Avatar
Webdoc

Community Member, 349 Posts

20 November 2010 at 5:57am

i use also the show in dataobject maybe there is some function needed also in dataobject.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

20 November 2010 at 7:16am

Like I said, your Categories() function doesn't return anything. That's the problem.

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
Webdoc

Community Member, 349 Posts

20 November 2010 at 7:20am

made it from your example.

Can u figure out what can be wrong

Avatar
UncleCheese

Forum Moderator, 4102 Posts

20 November 2010 at 7:44am

This function:

public function Categories() {
$ret = new DataObjectSet();
foreach(singleton('Bike')->dbObject('BikeCategory')->enumValues() as $cat) {
$ret->push(new ArrayData(array(
'CategoryName' => $cat,
'Bikes' => DataObject::get("Bike","BikeCategory = '$cat'")
)));
}
}

has no return..

you need to add:

return $ret;

Go to Top