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

Having a problem displaying a DataObject in my page


Reply

5 Posts   917 Views

Avatar
Harley

4 December 2010 at 6:48am Community Member, 153 Posts

Hi,

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(){
      parent::init();
      $params = Director::urlParams();
      Requirements::css("DataBase/css/callerdatabase.css");
      Requirements::javascript("jsparty/jquery/jquery.js");
      Requirements::javascript("DataBase/javascript/jquery.tablesorter.min.js");
   }

   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?

Avatar
swaiba

4 December 2010 at 7:47am Forum Moderator, 1796 Posts

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

Avatar
Harley

4 December 2010 at 9:53am (Last edited: 4 December 2010 9:53am), Community Member, 153 Posts

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

Avatar
Mo

4 December 2010 at 1:39pm Community Member, 509 Posts

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?

Cheers,

Mo

Avatar
Harley

5 December 2010 at 12:58am Community Member, 153 Posts

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!