Jump to:

23007 Posts in 11866 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Having a problem displaying a DataObject in my page

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

Page: 1
Go to End
Author Topic: 853 Views
  • Harley
    Avatar
    Community Member
    153 Posts

    Having a problem displaying a DataObject in my page Link to this post

    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?

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Having a problem displaying a DataObject in my page Link to this post

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

  • Harley
    Avatar
    Community Member
    153 Posts

    Re: Having a problem displaying a DataObject in my page Link to this post

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

  • Mo
    Avatar
    Community Member
    485 Posts

    Re: Having a problem displaying a DataObject in my page Link to this post

    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

  • Harley
    Avatar
    Community Member
    153 Posts

    Re: Having a problem displaying a DataObject in my page Link to this post

    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!

    853 Views
Page: 1
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.