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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Having a problem displaying a DataObject in my page

Go to End

5 Posts   1174 Views


Community Member, 165 Posts

4 December 2010 at 6:48am


I'm having some difficulty with displaying a dataobject on my page. All I get is a 404 Page not found.

The function I'm using in my controller is this:

class DataBaseResults_Controller extends Page_Controller{

public function init(){
$params = Director::urlParams();

public function ResultsView(){
$params = Director::urlParams();
return (isset($params['Action']) && $params['Action'] == 'viewcase');

and in my template:

<a href="{$Top.Link}viewcase/{$ID}"mce_href="{$Top.Link}viewcase/{$ID}" title="Go to the $Title.XML page" class="$LinkingMode levela">View</a>

<% if ResultsView %>
<% if getDisplayResultsDetails %>
<% control getDisplayResultsDetails %>
### display results here ###
<% end_control %>
<% end_if %>
<% end_if %>

I've used this method before in earlier versions of Silverstripe and can't understand why this won't work, any ideas where I'm going wrong?


Forum Moderator, 1899 Posts

4 December 2010 at 7:47am

do you have the appropriate director rule for DataBaseResults in your _config.php?


Community Member, 165 Posts

4 December 2010 at 9:53am

Edited: 04/12/2010 9:53am

No, never had to do this before, what does this entail?


Community Member, 541 Posts

4 December 2010 at 1:39pm

What version of Silverstripe are you running? If this method is called when a custom action is used in the URL, you will need to add the 'allowed_actions' static to your controller (as of 2.4).

Also, it maty sound silly, but is the page you are trying to access named correctly and of the DataBaseResults type? Also, I am guessing you also have a Page extension that goes with that controller extension?

Also, could you include the code for: getDisplayResultsDetails()? The error might be related to that?




Community Member, 165 Posts

5 December 2010 at 12:58am

Guys, thank you so much!

I knew it would be something simple, yes it turns out I'd not set the "allowed actions", something I have not looked at in SS2.4.

Thank you again!