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

Probable template error. Please, help!


Go to End


2 Posts   1048 Views

Avatar
Craneway

20 Posts

28 January 2008 at 11:55am

Edited: 28/01/2008 12:00pm

Hi, I am making a turist site, where TourPages are listed in a TourHolder Page. But also the latest tour is shown on a HomePage. I made this according to the 2nd tutorial.

The HomePage works fine until a TourHolder page is created. After this when previewing the HomePage in a Stage (or Live) mode I recieve the following error: "Error. The website server has not been able to respond to your request." And the same error on site flush. The HomePage URL is unchanged, i.e. "home".

Though the TourHolder and the TourPages are displayed correctly in Stage mode.

I suppose I have done smth wrong with the templates but can't figure it out. Could you, please, check it out?

HomePage.php

<?php
/**
 * Defines the HomePage page type
 */ 
class HomePage extends Page {
   static $db = array(
   "Information" => "HTMLText",
   "News" => "HTMLText"
);
   static $has_one = array(
   );
 function getCMSFields() {
   $fields = parent::getCMSFields();
 
   $fields->addFieldToTab("Root.Content.Main", new HTMLEditorField("Information"), "Content");
   $fields->addFieldToTab("Root.Content.Main", new HTMLEditorField("News"), "Content");
    	
   return $fields;
}	
}
 
class HomePage_Controller extends Page_Controller {
	function LatestTour() {
  		$newtour = DataObject::get_one("TourHolder");
  		return ($newtour) ? DataObject::get("TourPage", "ParentID = $newtour->ID", "Date DESC", "", 1) : false;
	}
}

?>

HomePage.ss fragment:

<div class="leftblock">
		  	<% control LatestTour %>        
            	<h3><span class="new">NEW!</span><a href="$Link" title="&quot;{$Title}&quot;">$Title</a></h3>
                <p>$Content.FirstParagraph <a href="$Link" title="&quot;{$Title}&quot;"><span class="arrow"> &rarr;</span></a></p>
			<% end_control %>
          </div>  

Avatar
Craneway

20 Posts

28 January 2008 at 1:24pm

Sorry, guys. I solved the problem.

"Date DESC" parameter should be removed. Now works fine.