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.

Archive /

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

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

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


Go to End


3 Posts   1894 Views

Avatar
Piklets

Community Member, 36 Posts

17 October 2008 at 7:47pm

Edited: 17/10/2008 7:47pm

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

Avatar
Sean

Forum Moderator, 922 Posts

17 October 2008 at 10:34pm

Edited: 17/10/2008 10:36pm

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

Avatar
Piklets

Community Member, 36 Posts

17 October 2008 at 10:59pm

Edited: 18/10/2008 5:16pm

- 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?