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.

Archive

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

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

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


Reply

3 Posts   1527 Views

Avatar
Piklets

17 October 2008 at 7:47pm (Last edited: 17 October 2008 7:47pm), Community Member, 36 Posts

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

17 October 2008 at 10:34pm (Last edited: 17 October 2008 10:36pm), Forum Moderator, 921 Posts

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

17 October 2008 at 10:59pm (Last edited: 18 October 2008 5:16pm), Community Member, 36 Posts

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