17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1369 Views |
-
Error: The website server has not been able to respond to your request.

17 October 2008 at 7:47pm Last edited: 17 October 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
-
Re: Error: The website server has not been able to respond to your request.

17 October 2008 at 10:34pm Last edited: 17 October 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
-
Re: Error: The website server has not been able to respond to your request.

17 October 2008 at 10:59pm Last edited: 18 October 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?
| 1369 Views | ||
|
Page:
1
|
Go to Top |


