Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Error: The website server has not been able to respond to your request.

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1518 Views
  • Piklets
    Avatar
    Community Member
    36 Posts

    Error: The website server has not been able to respond to your request. Link to this post

    Hey everyone!

    With my code (http://pastebin.com/m3e33dbd4) it comes up with this error:
    The website server has not been able to respond to your request.

    It seems to be a problem with $dataobjectset->toArray()

    - David

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Error: The website server has not been able to respond to your request. Link to this post

    You've got a lot of HTML in the PHP code. This could be offloaded to the templates, which makes life a lot easier!

    Generally it's better to return a DataObject (or DataObjectSet) from the function in your controller, and then using that in the templates with a <% control %> loop.

    e.g.

    <?php

    class ReportPage extends Page {

    }

    class ReportPage_Controller extends Page_Controller {

    function ViewInfo() {
    $userid = (int) $_GET['id'];
    return DataObject::get_one('MedCheck', "UserID = {$userid}");
    }

    }

    ?>

    Then, in your template (ReportPage.ss inside templates/Layout):

    <% if ViewInfo %>
    <% control ViewInfo %>
    $SomePropertyHere $ID
    <% end_control %>
    <% else %>
    <p>No view info (insert better text here ;-))</p>
    <% end_if %>

    $SomePropertyHere refers to some item in your $db or $has_one or similar array on the MedCheck class, which I assume is a DataObject or a Page subclass.

    I'm sure you'll have questions. Please do reply!

    Sean

  • Piklets
    Avatar
    Community Member
    36 Posts

    Re: Error: The website server has not been able to respond to your request. Link to this post

    - When you use <%control... isn't that a foreach sort of function? Is it necessary since you are using DataObject::get_one?

    EDIT: I've figured out a heck of a lot of things I posted here, it's awesome!

    Also, I would like have a WYSIWYG editor in my website, is there an easy way to do that?
    -I'm guessing manually. What database field type would suit this?

    1518 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.